所以我试图运行我的Android应用,但出现以下错误:
Duplicate class org.jetbrains.annotations.Contract found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.Nls found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.NonNls found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.NotNull found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.Nullable found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.PropertyKey found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Duplicate class org.jetbrains.annotations.TestOnly found in modules annotations-13.0.jar (org.jetbrains:annotations:13.0) and jetified-kotlin-compiler-embeddable-1.3.21.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.21)
Go to the documentation to learn how to Fix dependency resolution errors.
我无法真正解决这类错误,因为我甚至没有在整个应用程序中以任何方式使用Kotlin。它被配置为Java应用程序。
我的build.gradle(模块:应用程序)看起来像这样:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.app"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude "**/kotlin/**"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.journeyapps:zxing-android-embedded:2.0.1@aar'
implementation 'com.journeyapps:zxing-android-integration:2.0.1@aar'
implementation 'com.google.zxing:core:3.2.1'
implementation 'me.dm7.barcodescanner:zxing:1.9'
// https://mvnrepository.com/artifact/org.web3j/parity
implementation 'org.web3j:core:4.5.7'
implementation 'org.web3j:parity:4.5.5'
}
另一个build.gradle(项目:App)看起来像这样:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
[我从具有相似重复类错误的人那里阅读了关于StackOverflow的其他问题/答案后,将mavenCentral()
和jcenter()
添加到了存储库中。
在gradle.properties中添加
android.useAndroidX=true
android.enableJetifier=true