1

I added firebase to android. It used to work fine but after pulling from github it shows the errors below:

Duplicate class com.google.android.gms.measurement.AppMeasurement found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.2.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:17.2.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:17.2.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:17.2.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:17.2.0) and classes.jar (com.google.firebase:firebase-analytics-impl:10.0.1)

I tried deleting a few lines in gradle file but it doesn't seem to work.

My gradle file is:

apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.1" defaultConfig { applicationId "com.example.agrismart" minSdkVersion 23 targetSdkVersion 29 versionCode 1 versionName "1.0" 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.firebaseui:firebase-ui-database:6.0.2' implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' implementation 'com.github.barteksc:android-pdf-viewer:2.8.2' androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' implementation'com.google.firebase:firebase-auth:18.1.0' implementation 'com.google.firebase:firebase-analytics:17.2.0' implementation 'com.google.firebase:firebase-database:19.1.0' implementation 'com.google.firebase:firebase-core:15.0.0' implementation 'com.firebase:firebase-client-android:2.4.0' implementation 'com.google.android.gms:play-services:10.0.1' } apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' 

How can I resolve these problems?

4
  • 1
    this build.gradle is a mess and also uses age-old versions mixed with new versions. Commented Sep 29, 2019 at 11:53
  • 1
    Try using the latest versions and remove implementation 'com.firebase:firebase-client-android:2.4.0'. Commented Sep 29, 2019 at 11:57
  • @AlexMamo I was merely referring to play-services:10.0.1 and apply plugin: 'com.android.application' probably should be on top... also the conflict hints for duplicate play-services pulled in due to version mismatch. Commented Sep 29, 2019 at 11:58
  • @MartinZeitler Totally agree ;) Commented Sep 29, 2019 at 12:12

1 Answer 1

1

Update the following:

 implementation 'com.google.firebase:firebase-core:15.0.0' 

into this:

 implementation 'com.google.firebase:firebase-core:17.2.0' 

Remove the following dependency:

 implementation 'com.firebase:firebase-client-android:2.4.0' 

Since this is used in the old firebase version.

According to the docs:

Note: Don't use the combined play-services target. It brings in dozens of libraries, bloating your application. Instead, specify only the specific Google Play services APIs your app uses.

Therefore remove:

 implementation 'com.google.android.gms:play-services:10.0.1' 

And use the specific service that you need in the app (Also use the versions found in the following page):

https://developers.google.com/android/guides/setup

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.