So I'm trying to run my Android App but I get following Errors:
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.
I can't really wrap my head around these kinds of errors since I'm not even using Kotlin in any way in my entire app. It's configured as a Java app.
My build.gradle (Module: App) looks like this:
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'
}
The other build.gradle (Project: App) looks like this:
// 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
}
I added mavenCentral()
and jcenter()
to the repositories after I read other questions/answers on StackOverflow from people with similar Duplicate Class Errors.