Gradle Error:任务':app:processDebugGoogleServices'的执行失败

bra*_*ker 67 android gradle build.gradle

我正在关注此链接以在我的Android应用中集成Google登录.https://developers.google.com/identity/sign-in/android/start-integrating 如上面给定页面的最后一步所示,我们必须包含依赖项

 compile 'com.google.android.gms:play-services-auth:8.3.0' 
Run Code Online (Sandbox Code Playgroud)

在app-level build.gradle文件中,但这样做并构建项目错误来说

Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.
Run Code Online (Sandbox Code Playgroud)

的build.gradle(模块:APP)

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.brainbreaker.socialbuttons"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.google.android.gms:play-services-auth:8.3.0'
}
Run Code Online (Sandbox Code Playgroud)

在build.gradle文件中,编译依赖行compile 'com.google.android.gms:play-services-auth:8.3.0'显示错误

所有com.google.android.gms库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).找到版本8.3.0,8.1.0.示例包括com.google.android.gms:play-services-base:8.3.0和com.google.android.gms:play-services-measurement:8.1.0有一些库,工具和库的组合,是不兼容的,或可能导致错误.一个这样的不兼容性是使用不是最新版本的Android支持库版本(或者特别是低于targetSdkVersion的版本)进行编译.

以下是gradle构建的消息.

Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :social_buttons:generateDebugSources, :social_buttons:generateDebugAndroidTestSources, :social_buttons:compileDebugSources, :social_buttons:compileDebugAndroidTestSources]
:clean UP-TO-DATE
:app:clean
:social_buttons:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library
:app:prepareComAndroidSupportDesign2301Library
:app:prepareComAndroidSupportSupportV42301Library
:app:prepareComGoogleAndroidGmsPlayServicesAds810Library
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics810Library
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth830Library
:app:prepareComGoogleAndroidGmsPlayServicesBase830Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement830Library
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement810Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
:app:processDebugGoogleServices FAILED
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.
Information:BUILD FAILED
Information:Total time: 3.49 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
Run Code Online (Sandbox Code Playgroud)

我无法看到这个版本冲突的任何出路.任何帮助表示赞赏.

sey*_*eon 158

我有同样的问题.但现在我已经修好了.

你应该删除一行 apply plugin: 'com.google.gms.google-services'

因为"com.android.application"包已经有相同的包.

  • 那么为什么https://developers.google.com/analytics/devguides/collection/android/v4/上的说明会说要应用这个插件? (10认同)
  • 如果您的项目级 gradle 文件中有 `com.google.gms:google-services:3.1.0`,则删除应用级 gradle 中的最后一行:`apply plugin: 'com.google.gms.google-服务`。如果您在项目级别有 3.0.0 版,请保持该行不变。奇怪,但它有效。 (4认同)
  • 切勿从 gradle 中删除应用插件:“com.google.gms.google-services”。有时您使用 com.google.gms:google-services:3.1.0 ,而没有 apply plugin: 'com.google.gms.google-services' 您的 gradle 构建成功。但这是完全错误的!!! (3认同)
  • 您必须在文件末尾应用插件. (2认同)
  • 这个答案是完全错误的。它可能会成功,但如果您使用任何依赖于谷歌服务的服务,它稍后就会失败。 (2认同)

The*_*ann 34

我遇到了同样的问题并通过在项目级build.gradle的依赖项中添加以下行来解决它:

classpath 'com.google.gms:google-services:3.0.0'

有关完整的工作示例,请查看github上的以下项目.

希望这可以帮助 :)


sco*_*yab 15

我发现同样的错误抱怨在从8.3切换到8.4时混合谷歌播放服务版本.奇怪的是,我看到了我没有使用的app-measurement lib的参考.

我想也许我的应用程序的一个依赖项引用了旧版本,所以我跑去./gradlew app:dependencies查找有问题的库(非是).

但在任务输出的顶部,我发现了一条错误消息,指出无法找到谷歌插件并默认为谷歌播放服务8.3.我使用示例项目 @TheYann链接进行比较.我的设置是相同的,除了我apply plugin: 'com.google.gms.google-services'在我的应用程序的build.gradle文件的顶部应用.我移动到文件的底部,并修复了gradle编译错误.

  • @IgorGanapolsky您是否已将应用插件:'com.google.gms.google-services'移至app build.gradle的底部? (3认同)

Sun*_*tam 7

defaultConfigAndroid/app/build.gradle为 Flutter 应用程序连接 Firebase 后,确保您已经完成了这两件事。

1) 无论您在创建 Firebase android 项目时输入什么包名称,都应该与您applicationIddefaultConfig.

2)multiDexEnabled truedefaultConfig.

所以defaultConfig{}现在应该看起来像这样

defaultConfig {
    applicationId "com.companyName.appName"
    minSdkVersion 16
    targetSdkVersion 27
    multiDexEnabled true
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Run Code Online (Sandbox Code Playgroud)


Thi*_*van 5

我也面临同样的问题。但是我忘了在我的项目中添加google-services.json。您可以从 Google 获取此文件。