这些是我在构建应用程序时在Logcat中的错误.我正在将这个应用程序从一个Firebase帐户转移到另一个帐户.但依赖关系正在抛出这样的错误. 如何清除这些错误?应用程序不是在构建,而是在应用程序构建过程中出现错误:
Duplicate class com.google.firebase.auth.ktx.AuthKt found in modules jetified-
firebase-auth-22.3.0-runtime (com.google.firebase:firebase-auth:22.3.0) and
jetified-firebase-auth-ktx-21.1.0-runtime (com.google.firebase:firebase-auth-
ktx:21.1.0)
Duplicate class com.google.firebase.database.ktx.ChildEvent found in modules
jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.ChildEvent$Added found in modules
jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.ChildEvent$Changed found in modules
jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.ChildEvent$Moved found in modules
jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.ChildEvent$Removed found in modules
jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.DatabaseKt found in modules
jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.DatabaseKt$childEvents$1 found in
modules jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.DatabaseKt$childEvents$1$1 found in
modules jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.DatabaseKt$childEvents$1$listener$1
found in modules jetified-firebase-database-20.3.0-runtime
(com.google.firebase:firebase-database:20.3.0) and jetified-firebase-database-ktx-
20.1.0-runtime (com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.DatabaseKt$getValue$1 found in
modules jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.DatabaseKt$getValue$2 found in
modules jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.DatabaseKt$snapshots$1 found in
modules jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.DatabaseKt$snapshots$1$1 found in
modules jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.DatabaseKt$snapshots$1$listener$1
found in modules jetified-firebase-database-20.3.0-runtime
(com.google.firebase:firebase-database:20.3.0) and jetified-firebase-database-ktx-
20.1.0-runtime (com.google.firebase:firebase-database-ktx:20.1.0)
Duplicate class com.google.firebase.database.ktx.FirebaseDatabaseKtxRegistrar found
in modules jetified-firebase-database-20.3.0-runtime (com.google.firebase:firebase-
database:20.3.0) and jetified-firebase-database-ktx-20.1.0-runtime
(com.google.firebase:firebase-database-ktx:20.1.0)
Go to the documentation to learn how to Fix dependency resolution errors.
我的build.gradle代码是:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
}
android {
compileSdk 34
defaultConfig {
applicationId "com.socialtap.app"
minSdk 24
targetSdk 33
versionCode 3
versionName "1.3"
multiDexEnabled = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
namespace 'com.socialtap.app'
}
dependencies {
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.6'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.6'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// Firebase
implementation platform('com.google.firebase:firebase-bom:31.0.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-database-ktx'
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.firebase:firebase-storage-ktx'
//declare the dependency for the Google Play services library and specify its version
implementation 'com.google.android.gms:play-services-auth:20.7.0'
//multiDex
implementation 'androidx.multidex:multidex:2.0.1'
// image
implementation "com.github.bumptech.glide:glide:4.13.2"
//MaterialSpinner
implementation 'com.jaredrummler:material-spinner:1.3.1'
//sdp
implementation 'com.intuit.sdp:sdp-android:1.1.0'
//TedImagePicker
implementation 'com.github.dhaval2404:imagepicker:2.1'
//Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4'
//CircleImageView
implementation 'de.hdodenhof:circleimageview:3.1.0'
//Loader
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
//Retrofit and GSON
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.3'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.3'
//ImageCompressor
implementation 'id.zelory:compressor:3.0.1'
//NFC
implementation 'com.google.guava:guava:31.0.1-jre'
//QRCode
implementation 'com.google.zxing:core:3.5.1'
//Facebook Login
implementation 'com.facebook.android:facebook-login:14.1.1'
//Zoomable Image
implementation 'com.jsibbold:zoomage:1.3.1'
implementation 'androidx.test.ext:junit-ktx:1.1.5'
implementation 'androidx.test:monitor:1.6.1'
implementation 'com.google.firebase:firebase-auth:22.3.0'
implementation 'com.google.firebase:firebase-database:20.3.0'
testImplementation 'junit:junit:4.13.2'
//QRCodeScanner
implementation 'com.github.yuriy-budiyev:code-scanner:2.3.2'
implementation 'com.github.kenglxn.QRGen:android:3.0.1'
//Permissions
implementation 'com.karumi:dexter:6.2.3'
}
另一个gradle文件:
// Top-level build file where you can add configuration options common to all sub-
projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0'
classpath 'com.google.gms:google-services:4.4.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}