I am building an android application in android studio but am having trouble with duplicate dependencies.
Duplicate class javax.inject.Inject found in modules jetified-javax.inject-1.jar (javax.inject:javax.inject:1) and jetified-javax.inject-2.5.0-b42.jar (org.glassfish.hk2.external:javax.inject:2.5.0-b42)
Both these dependencies were quite useful to me and i tried excluding the offending part of the dependencies from either of them which just ended up breaking one or the other.
I have been reading about shadow jars which from what i heard of sounded like a magic bullet so i tried it. From what i had read and heard you just added it as a dependency and it magically fixed everything. I tried adding it and i was still getting the error but i read online it is necessary to have the java or groovy plugin if you want it to work with out a lot of work. Either of these makes android studio very unhappy as android has its own slightly modified java or something.
Advice on how to get the shadow jar working would be much appreciated, but also if anyone has any other work arounds that would let me keep using the two clashing dependencies i would love to hear. I sorry if i made some newbie mistakes.
My gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.scrood"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.github.jengelman.gradle.plugins:shadow:6.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.squareup.picasso:picasso:2.5.1'
implementation 'org.glassfish.jersey.core:jersey-client:2.27'
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson:2.27'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.10.4'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.4'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation ('com.google.android.libraries.places:places:2.3.0')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}