Reputation: 19190
I use version 2 of WorkManager that is in the androidX package.
I also use another library which uses v1 of WorkManager which is in the Arch component package.
When I sync the project, sync finishes successfully, but when I try to build the project. I get the following error that says you have duplicate values.
Version I use in my Gradle:
"androidx.work:work-runtime-ktx:2.0.1"
Version added to the library:
'android.arch.work:work-runtime-ktx:1.0.1'
The error:
Duplicate class androidx.work.ArrayCreatingInputMerger found in modules classes.jar (android.arch.work:work-runtime:1.0.0-rc01) and classes.jar (androidx.work:work-runtime:2.0.1)
Duplicate class androidx.work.BackoffPolicy found in modules classes.jar (android.arch.work:work-runtime:1.0.0-rc01) and classes.jar (androidx.work:work-runtime:2.0.1)
Duplicate class androidx.work.Configuration found in modules classes.jar (android.arch.work:work-runtime:1.0.0-rc01) and classes.jar (androidx.work:work-runtime:2.0.1)
Duplicate class androidx.work.Configuration$Builder found in modules classes.jar (android.arch.work:work-runtime:1.0.0-rc01) and classes.jar (androidx.work:work-runtime:2.0.1)
...
I also have added these to my gradle.properties
:
android.useAndroidX=true
android.enableJetifier=true
Upvotes: 3
Views: 1975
Reputation: 604
In cases where you don't want a dependency from a third party library, you can simply exclude it out of that library.
In your case, you can exclude android.arch
work manager and add your own androidX
work manager instead.
Something similar to:
implementation('your_library') {
exclude group :'android.arch.work:work-runtime-ktx'
}
Upvotes: 4
Reputation: 1253
The conflict is because of the two workmanager dependencies. Try removing the second one i.e. android.arch.work:work-runtime-ktx:1.0.1
. And migrate your code with respect to the androidx
version
Upvotes: 0