Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program type already present: com.google.android.gms.common.api.zzf

When I run my application in the android studio, I get the following error.

Program type already exists: com.google.android.gms.common.api.zzf

firebase-core warning -> All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 12.0.1, 10.0.1. Examples include com.google.android.gms:play-services-basement:12.0.1 and com.google.android.gms:play-services-ads:10.0.1 less... (Ctrl+F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.fay.flow"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    testImplementation 'junit:junit:4.12'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.github.bumptech.glide:glide:4.6.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.google.firebase:firebase-core:12.0.1'
    implementation 'com.google.firebase:firebase-database:12.0.1'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-moshi:2.3.0'
    implementation 'com.facebook.android:audience-network-sdk:4.28.0'
    implementation 'org.jsoup:jsoup:1.7.3'
    implementation 'com.jakewharton:butterknife:8.8.1'
    implementation 'com.r0adkll:slidableactivity:2.0.6'
    implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'
    implementation 'com.etsy.android.grid:library:1.0.5'

}

apply plugin: 'com.google.gms.google-services'
like image 855
TurkC Avatar asked Apr 08 '18 13:04

TurkC


4 Answers

Had the same error. How to fix it:

In your dependencies you're using:

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

And the warning says:

firebase-core warning -> All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 12.0.1, 10.0.1. Examples include com.google.android.gms:play-services-basement:12.0.1 and com.google.android.gms:play-services-ads:10.0.1 less...

try to add this dependency with your version - 12.0.1 (not 10.0.1):

implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
like image 192
Vitaly Zinchenko Avatar answered Nov 10 '22 05:11

Vitaly Zinchenko


The solution for me

implementation ('com.facebook.android:audience-network-sdk:4.28.0',{
    exclude group: 'com.google.android.gms'
})
like image 30
TurkC Avatar answered Nov 10 '22 05:11

TurkC


what is ZZF, ZZg,ZZH, ZZA etc. whatever you get error of like this solve it by changing dependency level . some times it due to dependency missing .

its normally occurring due to your dependency mismatch i face many times and solved by changing dependency level you can see below two cases in first i got error of zzf,but second time changing first line ads dependency so now its working fine

first case:

implementation 'com.google.android.gms:play-services-ads:15.0.1'


implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.daimajia.numberprogressbar:library:1.2@aar'
implementation 'com.amitshekhar.android:android-networking:0.2.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'org.mapsforge:mapsforge-map-android:0.8.0'
implementation 'com.caverock:androidsvg:1.2.2-beta-1'
testImplementation 'junit:junit:4.12'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
    transitive = true
}
implementation 'com.google.android.gms:play-services-analytics:10.0.1'

second case:

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

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.daimajia.numberprogressbar:library:1.2@aar'
implementation 'com.amitshekhar.android:android-networking:0.2.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'org.mapsforge:mapsforge-map-android:0.8.0'
implementation 'com.caverock:androidsvg:1.2.2-beta-1'
testImplementation 'junit:junit:4.12'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
    transitive = true
}
implementation 'com.google.android.gms:play-services-analytics:10.0.1'

in first case i get the error ,but when i change ads dependency in the first line you can see to level 10 its correct you will face this error in many key words with zzf, zzg,but its every time due to dependency mismatching at high level so change them hopefully you will enjoy it.

like image 39
Najaf Ali Avatar answered Nov 10 '22 03:11

Najaf Ali


I had a similar issue when I was adding two different packages to my android build (using react native).

The problem was they were using two different versions of google play services. I was able to resolve it using option 1:

Option 1: Use Project-Wide Gradle Config:

You can define project-wide properties (recommended) in your root /android/build.gradle, and let the library auto-detect the presence of the following properties:

buildscript {...}
allprojects {...}

/**
Project-wide Gradle configuration properties (replace versions as appropriate)
*/

ext {
  compileSdkVersion   = 25
  targetSdkVersion    = 25
  buildToolsVersion   = "25.0.2"
  supportLibVersion   = "25.0.2"
  googlePlayServicesVersion = "11.6.2"
  androidMapsUtilsVersion = "0.5+"
}

Option 2: Use Specific Gradle Config:

If you do not have project-wide properties defined or want to use a different Google Play-Services version, use the following instead (switch 11.6.2 for the desired version):

  ...
  dependencies {
  ...
  implementation(project(':react-native-google-places')){
      exclude group: 'com.google.android.gms', module: 'play-services-base'
      exclude group: 'com.google.android.gms', module: 'play-services-places'
      exclude group: 'com.google.android.gms', module: 'play-services-location'
  }
  implementation 'com.google.android.gms:play-services-base:11.6.2'
  implementation 'com.google.android.gms:play-services-places:11.6.2'
  implementation 'com.google.android.gms:play-services-location:11.6.2'
  }

In my project I simply added:

ext {
  googlePlayServicesVersion = "12.0.1"
}

to my android/build.gradle file as per option 1.

like image 5
Robert Stevens Avatar answered Nov 10 '22 04:11

Robert Stevens