在Android Studio中,使用Java应用程序时出现多个重复的Kotlin类错误。

huangapple go评论86阅读模式
英文:

Getting multiple duplicate kotlin classes errors with a Java app in android studio

问题

在尝试构建我的Java应用程序时,我遇到了多个重复的Kotlin类错误。错误中提到的类同时在"org.jetbrains.kotlin:kotlin-stdlib:1.8.20"和"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21"中声明。

我的依赖项如下:

  • implementation 'com.google.android.gms:play-services-maps:18.1.0'
  • implementation 'com.google.android.gms:play-services-location:21.0.1'
  • implementation 'org.mapsforge:mapsforge-map-android:0.19.0'
  • implementation 'com.caverock:androidsvg:1.4'
  • implementation 'org.mapsforge:mapsforge-poi-android:0.19.0'
  • implementation 'org.mapsforge:sqlite-android:0.19.0'
  • implementation 'org.mapsforge:mapsforge-themes:0.19.0'
  • implementation 'org.osmdroid:osmdroid-android:6.1.16'
  • implementation platform('com.google.firebase:firebase-bom:32.1.1')
  • implementation 'com.google.firebase:firebase-crashlytics'
  • implementation 'com.google.firebase:firebase-analytics'
  • implementation 'androidx.activity:activity:1.7.2'
  • implementation 'androidx.fragment:fragment:1.6.0'

使用Gradle插件版本8.0.2和Gradle版本8.2,构建工具版本34.0.0。

英文:

When trying to build my Java app, I get multiple duplicate Kotlin classes error. Classes in error are said to be declared in both "org.jetbrains.kotlin:kotlin-stdlib:1.8.20" and "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21".
My dependencies are :

	implementation 'com.google.android.gms:play-services-maps:18.1.0'
	implementation 'com.google.android.gms:play-services-location:21.0.1'
	implementation 'org.mapsforge:mapsforge-map-android:0.19.0'
	implementation 'com.caverock:androidsvg:1.4'
	implementation 'org.mapsforge:mapsforge-poi-android:0.19.0'
	implementation 'org.mapsforge:sqlite-android:0.19.0'
	implementation 'org.mapsforge:mapsforge-themes:0.19.0'
	implementation 'org.osmdroid:osmdroid-android:6.1.16'
	implementation platform('com.google.firebase:firebase-bom:32.1.1')
	implementation 'com.google.firebase:firebase-crashlytics'
	implementation 'com.google.firebase:firebase-analytics'
	implementation 'androidx.activity:activity:1.7.2'
	implementation 'androidx.fragment:fragment:1.6.0'

Using Gradle plugin version 8.0.2 and Gradle version 8.2, build tool version 34.0.0.

答案1

得分: 2

请尝试在build.gradle文件中,在声明依赖项后,像这样添加代码:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.activity:activity:1.7.2'
    implementation 'androidx.recyclerview:recyclerview:1.3.0'
    implementation 'androidx.core:core-splashscreen:1.0.1'
    implementation 'com.google.mlkit:image-labeling:17.0.7'
    implementation 'com.google.android.material:material:1.11.0-alpha01'
    implementation 'com.github.bumptech.glide:glide:4.15.1'
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
    implementation 'io.reactivex.rxjava3:rxjava:3.1.6'
}

configurations.implementation {
    exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
}

我几个月前遇到了类似的错误,这个方法解决了我的问题。
英文:

Try to add this in build.gradle right after declaring your dependencies like this:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.activity:activity:1.7.2'
    implementation 'androidx.recyclerview:recyclerview:1.3.0'
    implementation 'androidx.core:core-splashscreen:1.0.1'
    implementation 'com.google.mlkit:image-labeling:17.0.7'
    implementation 'com.google.android.material:material:1.11.0-alpha01'
    implementation 'com.github.bumptech.glide:glide:4.15.1'
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
    implementation 'io.reactivex.rxjava3:rxjava:3.1.6'
}

configurations.implementation {
    exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
}

I faced a similar error few months ago and this solved it for me.

huangapple
  • 本文由 发表于 2023年7月10日 15:07:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76651410.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定