I've read and tried a lot of post solution for this problem but there is something I am doing wrong because it is not working for me.
I have just updated Android to AndroidX which came with the dependency androidx.preference:preference:1.1.0-alpha04
. This dependency included the jar file named com.google.guava:listenablefuture:1.0@jar
. The problem is that com.google.common.util.concurrent.ListenableFuture
is found twice in the dependencies and this gives me an error when I build the project. I also found that the whole jar file (androidx.preference:preference:1.1.0-alpha04
) can be removed as the file that is in there is already in another dependency library.
I have tried to add some notations to exclude the library but none of them worked out unfortunatelly. The jar file keeps being added once I build the project.
build.gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation('org.ros.android_core:android_10:[0.3, 0.4)') {
exclude group: 'junit'
exclude group: 'xml-apis'
}
// e.g. official msgs
implementation 'org.ros.rosjava_messages:std_msgs:0.5.11'
implementation 'org.ros.rosjava_messages:sensor_msgs:1.12.7'
implementation 'org.ros.rosjava_messages:geometry_msgs:1.12.7'
implementation 'org.ros.rosjava_bootstrap:message_generation:0.3.3'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha5'
implementation ("androidx.preference:preference:1.1.0-alpha04", {
exclude group: 'com.google.guava'
})
implementation 'com.google.code.gson:gson:2.8.5'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.27.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
repositories {
mavenCentral()
}
The dependency that can be excluded:
What am I doing wrong or how should I actually exclude the jar file from the dependency?
EDIT: The reason I want to do this is because I get the following error:
Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules guava-12.0.jar (com.google.guava:guava:12.0) and listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)