Gradle同步失败:所有Firebase库必须高于或低于14.0.0

时间:2018-07-05 16:53:43

标签: java android firebase admob

我已经花了一段时间了,这让我发疯了。我已经研究了一些现有的Stack Overflow问题,但是没有任何效果。每当我添加AdMob广告单元所需的最后一行时,我都会不断收到此错误。人们似乎可以通过将该行的版本号更改为15.0.0来解决此问题,但是,正如您所看到的,我已经做到了。如果可以的话请帮忙。另外,这甚至不是我第一次使用广告单元。

Build.gradle(应用程序级别)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.coincalc.anduril.sharetale"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 2
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }

    lintOptions {
        abortOnError false
    }
}

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'
    implementation 'com.android.support:support-vector-drawable:26.1.0'
    implementation 'com.google.firebase:firebase-database:12.0.1'
    implementation 'com.google.firebase:firebase-auth:12.0.1'
    implementation 'com.android.support:support-v4:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.google.firebase:firebase-core:12.0.1'
    implementation 'com.google.android.gms:play-services-ads:15.0.0'
}

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

Build.gradle(项目级别)

buildscript {

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

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

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

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

3 个答案:

答案 0 :(得分:2)

在顶级build.gradle中更新以下类路径依赖项:

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

只有此插件的较新版本知道新的Firebase依赖项不再都必须处于同一版本。

Read this for more information.

答案 1 :(得分:1)

更改此:

 implementation 'com.google.firebase:firebase-database:12.0.1'
 implementation 'com.google.firebase:firebase-auth:12.0.1'
 compile 'com.google.firebase:firebase-core:12.0.1'

对此:

 implementation 'com.google.firebase:firebase-database:16.0.1'
 implementation 'com.google.firebase:firebase-auth:16.0.2'
 implementation 'com.google.firebase:firebase-core:16.0.1'

检查此以获取更多信息:

https://firebase.google.com/support/release-notes/android

答案 2 :(得分:1)

通过将依赖关系更改为以下内容,将Firebase依赖关系升级到最新版本:

implementation 'com.google.firebase:firebase-database:16.0.1'

implementation 'com.google.firebase:firebase-auth:16.0.2'

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

然后在您的项目级别Gradle文件中,将您的Google服务插件增​​加到4.0.0