Can't Build with firebase-config:16.0.0 and firebase-core:16.0.1

馋奶兔 提交于 2020-01-10 05:31:05

问题


When I build with the latest released versions of firebase-config and firebase-core, I get this error:

The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.4,15.0.4], [16.0.0,16.0.0]], but resolves to 16.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

How can I resolve this dependency conflict?

My project gradle file is:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-beta01'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

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

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

My app module gradle file is:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.myproject"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 201
        versionName "1.0.0"
        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'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'

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

    testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

回答1:


Oddly enough, the error does not occur when firebase-core is placed before other Firebase libs in the dependencies list:

dependencies {
    ...
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-config:16.0.0'
    ...
}



回答2:


yesterday, i was face same problem .it is easily solved by following dependencies.include these two in your app gradle and sync your project.

implementation 'com.google.android.gms:play-services-analytics:16.0.1'

implementation 'com.google.firebase:firebase-messaging:17.1.0'



来源:https://stackoverflow.com/questions/51025793/cant-build-with-firebase-config16-0-0-and-firebase-core16-0-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!