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

Tur*_*rkC 9 android firebase android-gradle-plugin

当我在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'
Run Code Online (Sandbox Code Playgroud)

Tur*_*rkC 13

我的解决方案

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


Vit*_*nko 7

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

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

implementation 'com.google.firebase:firebase-core:12.0.1'
Run Code Online (Sandbox Code Playgroud)

警告说:

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'
Run Code Online (Sandbox Code Playgroud)


Rob*_*ens 5

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

问题是他们正在使用两种不同版本的Google Play服务。我可以使用选项1来解决它:

选项1:使用Project-Wide Gradle Config:

您可以在根目录/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+"
}
Run Code Online (Sandbox Code Playgroud)

选项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'
  }
Run Code Online (Sandbox Code Playgroud)

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

ext {
  googlePlayServicesVersion = "12.0.1"
}
Run Code Online (Sandbox Code Playgroud)

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