Reputation: 41
I got this error when I try to generate signed apk for my project
Duplicate class com.google.android.gms.measurement.AppMeasurement found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:16.5.0) and classes.jar (com.google.firebase:firebase-analytics-impl:10.0.1) Duplicate class com.google.firebase.analytics.FirebaseAnalytics found in modules classes.jar (com.google.android.gms:play-services-measurement-api:16.5.0) and classes.jar (com.google.firebase:firebase-analytics-impl:10.0.1) Duplicate class com.google.firebase.analytics.FirebaseAnalytics$Event found in modules classes.jar (com.google.android.gms:play-services-measurement-api:16.5.0) and classes.jar (com.google.firebase:firebase-analytics-impl:10.0.1) Duplicate class com.google.firebase.analytics.FirebaseAnalytics$Param found in modules classes.jar (com.google.android.gms:play-services-measurement-api:16.5.0) and classes.jar (com.google.firebase:firebase-analytics-impl:10.0.1) Duplicate class com.google.firebase.analytics.FirebaseAnalytics$UserProperty found in modules classes.jar (com.google.android.gms:play-services-measurement-api:16.5.0) and classes.jar (com.google.firebase:firebase-analytics-impl:10.0.1)
Go to the documentation to learn how to Fix dependency resolution errors.
how do I fix It?
Upvotes: 4
Views: 10223
Reputation: 11
Reason: This error usually occurs due to depedencies using same functionality.
Solution: To revolve such issue is to comment: play-services because play-services-maps has same functions like play-services and also display locations on our android UI system. Please see below for solution.
//implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
Also checkout notable transitive dependencies: https://github.com/firebase/FirebaseUI-Android/releases
I hope its help solve so many developers project issues.
Upvotes: 1
Reputation: 1127
For those who face this type of issue in the future
Ensure that you are using the specific dependency of play services according to your requirements. In my case, I need a map dependency but I am importing the play service dependency which causes duplicate class issues with another firebase dependency.
Use this
def playServiceVersion = "17.0.0"
implementation "com.google.android.gms:play-services-maps:$playServiceVersion"
Instead of
def playServiceVersion = "17.0.0"
implementation "com.google.android.gms:play-services:$playServiceVersion"
For further information check the link below
https://developers.google.com/android/guides/setup
Upvotes: 2
Reputation: 2321
Try with
implementation("com.google.android.gms:play-services-gcm:$project.playServicesVersion") {
exclude group: 'com.google.android.gms'
}
You can Try including one by one the one which brings errors you apply
implementation("**API**") {
exclude group: 'com.google.android.gms'
}
NB $project.playServicesVersion
could be any of your versions you are using
Upvotes: 8