【问题标题】:Android Build execution failed due to incompatible library versions由于库版本不兼容,Android Build 执行失败
【发布时间】:2017-12-21 06:25:06
【问题描述】:

使用 firebase 实现 Google 登录。

这是我的项目级 build.gradle

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的 App 级 build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "wallet.mycoin"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "0.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okio:okio:1.5.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
    compile 'com.google.firebase:firebase-auth:11.8.0'
    compile 'com.google.android.gms:play-services-auth:11.8.0'
}

在构建时,我遇到了类似 >

的错误

错误:任务 ':app:processDebugGoogleServices' 执行失败。 请通过更新版本来修复版本冲突 google-services 插件(有关最新版本的信息是 可在 https://bintray.com/android/android-tools/com.google.gms.google-services/) 或将 com.google.android.gms 的版本更新为 9.0.0。

所有 firebase/gms 库必须使用完全相同的规范 (混合版本会导致运行时崩溃)找到版本 9.0.0 和 11.8.0。例子包括 com.google.firebase:firebase-analytics:9.0.0 和 com.google.android.gms:play-services-auth:11.8.0.

有一些库或工具和库的组合 不兼容,或者可能导致错误。一种这样的不兼容 使用不是 最新版本(或特定版本低于 targetSdkVersion)

项目中没有添加任何 Firebase 分析库。任何人都可以提出解决方案。构建失败。

【问题讨论】:

    标签: android firebase firebase-authentication build.gradle


    【解决方案1】:
    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okio:okio:1.5.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
    compile 'com.google.firebase:firebase-auth:11.8.0'
    compile 'com.google.android.gms:play-services-auth:11.8.0'
    }
    apply plugin: 'com.google.gms.google-services'
    

    使用这个文件,记得添加google-services配置文件。

    【讨论】:

    • 没有任何改变。我想知道我不想要地点和位置依赖性。你这是什么意思。还将 gson 降级到 2.6.2。
    • 您可以删除位置和地点,但从顶部删除 apply plugin: 'com.google.gms.google-services' 并附加在文件末尾。您可以使用相同的 gson ,我已经更新了答案
    • 只需将 > 从上到下放置。一切正常
    猜你喜欢
    • 2020-10-15
    • 2023-01-31
    • 2018-06-07
    • 2016-10-12
    • 1970-01-01
    • 2021-07-04
    • 1970-01-01
    • 2020-01-17
    • 1970-01-01
    相关资源
    最近更新 更多