After upgrading all libraries to androidx and to the latest versions of Firebase libraries
I got error with 2 different versions of dagger java files, link in the error message doesn't work. Problem occurs at step :app:checkDebugDuplicateClasses
.
I do not use dagger directly in my code, using
./gradlew app:dependencies
I found what com.google.android.gms:play-services-cast-framework:17.1.0
uses com.google.dagger:dagger:2.22
, but no info about 1.2.2
.
Cause 1: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class dagger.Lazy found in modules dagger-1.2.2.jar (dagger-1.2.2.jar) and dagger-2.22.jar (com.google.dagger:dagger:2.22)
Duplicate class dagger.MembersInjector found in modules dagger-1.2.2.jar (dagger-1.2.2.jar) and dagger-2.22.jar (com.google.dagger:dagger:2.22)
Duplicate class dagger.Module found in modules dagger-1.2.2.jar (dagger-1.2.2.jar) and dagger-2.22.jar (com.google.dagger:dagger:2.22)
Duplicate class dagger.Provides found in modules dagger-1.2.2.jar (dagger-1.2.2.jar) and dagger-2.22.jar (com.google.dagger:dagger:2.22)
Duplicate class javax.inject.Inject found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Named found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Provider found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Qualifier found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Scope found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Duplicate class javax.inject.Singleton found in modules javax.inject-1.jar (javax.inject-1.jar) and javax.inject-1.jar (javax.inject:javax.inject:1)
Go to the documentation to learn how to Fix dependency resolution errors.
The easiest way is to analyze dependencies.
Run in console:
./gradlew -q dependencies app:dependencies
After receiving list of dependencies in the console, go to Analyze
part (below Solution #2
).
In to app/build.gradle
(this with compileSdkVersion
, targetSdkVersion
or buildTypes
), at the top add:
apply plugin: 'project-report'
near one of them:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
which are on top.
Just from the console run:
./gradlew htmlDependencyReport
or from Android Studio
Tasks > other > htmlDependencyReport
In console you will find URL:
./gradlew htmlDependencyReport
> Task :app:htmlDependencyReport
See the report at: file:///Users/user_name/your_path/project_name/app/build/reports/project/dependencies/index.html
And go to the project ':app'
After clicking each of the position there are dependencies:
To expand all of them, you can in develper console such code:
$('#dependencies').html(function(index, html) {
return html.split('style="display: none;"')
.join('style="display: block;"')
.split('<h3 class="closed">')
.join('<h3>')
});
In your case you are searching phrase dagger:1
Or in the console:
Find in the report library name, and just exclude group
from this import.
In your build.gradle
(where you have all of dependencies) modify "problematic" library excluding dagger v1.
For example:
implementation("some.old.library.using.dagger1:1.0.0") {
exclude group: 'com.squareup.dagger', module: 'dagger'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With