【问题标题】:Program type already present: com.google.android.gms.common.api.zzf程序类型已经存在:com.google.android.gms.common.api.zzf
【发布时间】:2018-04-08 13:34:02
【问题描述】:

当我在 android studio 中运行我的应用程序时,我收到以下错误。

程序类型已存在:com.google.android.gms.common.api.zzf

firebase-core 警告 -> 所有 gms/firebase 库必须使用确切的 相同的版本规范(混合版本可能会导致运行时 崩溃)。找到版本 12.0.1、10.0.1。例子包括 com.google.android.gms:play-services-basement:12.0.1 和 com.google.android.gms:play-services-ads:10.0.1 少... (Ctrl+F1) 有一些库或工具和库的组合,它们 不兼容,或者可能导致错误。一种这样的不兼容性是 使用不支持的 Android 支持库版本进行编译 最新版本(或者特别是低于您的 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'

【问题讨论】:

标签: android firebase android-gradle-plugin


【解决方案1】:

我的解决方案

implementation ('com.facebook.android:audience-network-sdk:4.28.0',{
    exclude group: 'com.google.android.gms'
})

【讨论】:

  • 它对我有用,我的是: compile 'com.facebook.android:audience-network-sdk:5.+' 我改为 implementation ('com.facebook.android:audience-network- sdk:5.+',{ exclude group: 'com.google.android.gms' }) 它现在就像一个魅力。太好了!!!
【解决方案2】:

有同样的错误。如何解决:

在您使用的依赖项中:

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

警告说:

firebase-core 警告 -> 所有 gms/firebase 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 12.0.1、10.0.1。示例包括 com.google.android.gms:play-services-basement:12.0.1 和 com.google.android.gms:play-services-ads:10.0.1 更少...

尝试在您的版本中添加此依赖项 - 12.0.1(不是 10.0.1):

implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.android.gms:play-services-ads:12.0.1'

【讨论】:

    【解决方案3】:

    当我将两个不同的包添加到我的 android 构建(使用 react native)时,我遇到了类似的问题。

    问题是他们使用了两种不同版本的 google play 服务。我能够使用选项 1 解决它:

    选项 1:使用项目范围的 Gradle 配置:

    您可以在根目录 /android/build.gradle 中定义项目范围的属性(推荐),并让库自动检测以下属性的存在:

    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+"
    }
    

    选项 2:使用特定的 Gradle 配置:

    如果您没有定义项目范围的属性或想要使用不同的 Google Play-Services 版本,请改用以下版本(将 11.6.2 切换为所需版本):

      ...
      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'
      }
    

    在我的项目中,我只是添加了:

    ext {
      googlePlayServicesVersion = "12.0.1"
    }
    

    按照选项 1 到我的 android/build.gradle 文件。

    【讨论】:

      【解决方案4】:

      什么是 ZZF、ZZg、ZZH、ZZA 等。无论你遇到什么样的错误,都可以通过更改依赖级别来解决它。有时是因为缺少依赖。

      由于您的依赖项不匹配,它通常会发生,我多次遇到并通过更改依赖项级别来解决,您可以看到以下两种情况,首先我收到 zzf 错误,但第二次更改第一行广告依赖项,所以现在它工作正常

      第一种情况:

      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'
      

      第二种情况:

      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'
      

      在第一种情况下,我得到了错误,但是当我在第一行更改广告依赖项时,您可以看到它的正确级别为 10,您将在 zzf、zzg 的许多关键字中遇到此错误,但每次都是由于依赖项高水平不匹配,所以希望你会喜欢它。

      【讨论】:

        【解决方案5】:

        我解决了这个问题,希望对你有帮助。

        implementation 'com.google.android.gms:play-services-analytics:16.0.4'
        implementation 'com.google.android.gms:play-services-maps:16.0.0'
        implementation 'com.google.android.gms:play-services-location:16.0.0'
        implementation 'com.google.android.gms:play-services-base:16.0.1' 
        

        【讨论】:

          猜你喜欢
          • 2018-09-23
          • 2019-02-22
          • 1970-01-01
          • 2018-10-21
          • 2018-10-03
          • 2019-04-10
          • 2018-11-15
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多