play-services-map和firebase之间的依赖冲突

时间:2018-06-01 04:37:50

标签: android firebase gradle google-play-services

我试图将firebase添加到我已经启动的项目中,但是在build.gradle(app)中我在play-services-maps和firebase之间发生了依赖性冲突,我到处寻找并尝试更改版本号但是还是行不通。 这是build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.android.tencho.test"
        minSdkVersion 22
        targetSdkVersion 26
        versionCode 1
        versionName "1.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'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.gms:play-services:15.0.1'
//    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.google.code.gson:gson:2.2.+'
    compile 'com.google.firebase:firebase-core:16.0.0'

//    //Firebase Auth
    implementation 'com.google.firebase:firebase-auth:16.0.1'
//    //FirebaseUI Auth
    compile 'com.firebaseui:firebase-ui-auth:3.3.0'


}

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

Build.gradle(项目级别)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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

//        The google-services plugin has 2 main functions:
//        1) Process the google-services.json file and produce Android resources that can be used in your
//        application's code
//        2) Add dependencies for basic libraries required for the services you have enabled. This step requires
//        that the apply plugin: 'com.google.gms.google-services' line be at the bottom of your app/build.gradle file
//        so that no dependency collisions are introduced.
        classpath 'com.google.gms:google-services:4.0.1'


        // 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
}

1 个答案:

答案 0 :(得分:0)

您使用的是不一致的版本。

让我举一个简单的例子。

如果您使用的是google play服务11.8.0,那么firebase也应该是同一个版本..

compile 'com.google.android.gms:play-services:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.android.gms:play-services-maps:11.8.0'
compile 'com.google.firebase:firebase-crash:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'

所以需要注意的是,你使用的是不一致的版本。