如何解决在android studio中连接firebase时出现的重复类错误?

qmelpv7a  于 2023-05-15  发布在  Android
关注(0)|答案(1)|浏览(391)

我试图在Android中创建我的第一个项目,我不知道如何解决下面的错误。我在连接Firebase时在app:gradle build中得到了这个:
在模块kotlin-stdlib-1.8.10(org.jetbrains.kotlin:kotlin-stdlib:1.8.10)和kotlin-stdlib-jdk 8 -1.7.20(org. jetbrains. kotlin:kotlin-stdlib-jdk 8:1.7.20)中发现重复的类kotlin.collections.jdk8.CollectionsJDK8Kt
下面是我的Gradle代码:
插件{ id 'com.android.application' id 'kotlin-android' id 'com.google.gms.google-services'
}
android { namespace 'com.example.dealBreaker' compileSdk 33

defaultConfig {
    applicationId "com.example.dealBreaker"
    minSdk 26
    targetSdk 33
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

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'
}

}
依赖关系{

implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation platform('com.google.firebase:firebase-bom:32.0.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-config'
implementation 'com.google.firebase:firebase-crashlytics'

}
应用插件:'com.android.application'应用插件:'com.google.gms.google-services'

ajsxfq5m

ajsxfq5m1#

您将得到以下错误:
在模块kotlin-stdlib-1.8.10(org.jetbrains.kotlin:kotlin-stdlib:1.8.10)和kotlin-stdlib-jdk 8 -1.7.20(org. jetbrains. kotlin:kotlin-stdlib-jdk 8:1.7.20)中发现重复的类kotlin.collections.jdk8.CollectionsJDK8Kt
因为你已经在build.gradle中添加了两次firebase-analytics依赖项,一次是Kotlin,一次是Java:

implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-analytics'

由于您使用的是Kotlin,只需删除第二个并同步您的项目。错误应该消失了。

相关问题