已存在的计划类型:com.google.android.gms.common.api.zzf

时间:2018-04-08 13:34:03

标签: android firebase android-gradle

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

  

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

     

firebase-core warning - > 所有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 less ...(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'

5 个答案:

答案 0 :(得分:10)

我的解决方案

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

答案 1 :(得分:7)

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

在您正在使用的依赖项中:

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

警告说:

  

firebase-core warning - >所有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 less ...

尝试使用您的版本添加此依赖项 - 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'

答案 2 :(得分:5)

当我在我的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服务版本,请改用以下内容(切换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文件。

答案 3 :(得分:2)

我已解决此问题,希望对您有帮助。

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' 

答案 4 :(得分:1)

什么是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的许多关键字中,您都会遇到此错误,但由于依赖性而每次都高度不匹配,因此希望他们能有所改变。

相关问题