Firebase与Play服务之间的另一个版本冲突:com.google.android.gms:play-services-measurement-base

时间:2018-09-12 11:07:27

标签: android firebase google-play-services

我的应用使用了Google Play服务和Firebase的一部分,并且我想实现Firebase的应用内消息传递。我的google-services插件版本为v4.1.0,我的应用程序级别Gradle文件中的相关依赖项如下所示:

implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-analytics:16.0.3"
implementation "com.google.android.gms:play-services-ads:15.0.1"
implementation "com.google.android.gms:play-services-auth:16.0.0"
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.1' //this error only popped up when I added this line
implementation 'com.google.firebase:firebase-messaging:17.3.1'
implementation "com.google.firebase:firebase-core:16.0.3"
implementation "com.google.firebase:firebase-auth:16.0.3"
implementation "com.google.firebase:firebase-database:16.0.2"
implementation "com.google.firebase:firebase-config:16.0.0"
implementation "com.google.firebase:firebase-appindexing:16.0.1"

尝试构建我的应用时出现以下错误:

  

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.2,16.0.2]], but resolves to 16.0.2.

我知道其他一些问题,Firebase的文档说我必须将所有Firebase和Play Services的功能更新到最新版本,但这是最新的。我已经检查了两者的官方文档。

16.0.2仅匹配firebase-database依赖项,这与它有关系吗?还是其他原因(缺少或需要更新)?

编辑:根据要求,我的项目级Gradle文件:

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

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

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.1.0' // google-services plugin
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            //url "https://jitpack.io"
            url "https://maven.google.com"
        }
        flatDir {
            dirs 'libs'
        }
    }
}

还有我的app模块级Gradle文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    jcenter()
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    google()
}

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.picmix.mobile"
        minSdkVersion 15
        targetSdkVersion 27
        multiDexEnabled true
        buildConfigField "String", "EMBED", "\"\""

        versionCode 90      //Latest Version on Google Play
        versionName "7.7.8"

        packagingOptions{
            doNotStrip '*/mips/*.so'
            doNotStrip '*/mips64/*.so'
        }

        ndk {
            abiFilters "armeabi", "armeabi-v7a", "x86"
        }
    }

    signingConfigs {
        release {
            storeFile file("/Volumes/work/cert/android/picmix_key")
            storePassword "P1cMIx_M0B1l3_#2012#"
            keyAlias "picmix"
            keyPassword "P1cMIx_M0B1l3_#2012#"
        }
    }

    flavorDimensions "default"
    productFlavors {
        dev {
            minSdkVersion 21
            versionCode 1
            versionName "1.0"
        }

        dev2 {
            minSdkVersion 15
            versionCode 1
            versionName "1.0"
        }

        preload {
            buildConfigField "String", "EMBED", "\"huawei\""
        }

        prod {
            minSdkVersion 15
        }

        andgo {
            minSdkVersion 15
            versionCode 50000  + android.defaultConfig.versionCode
        }
//        lintOptions {
//            checkReleaseBuilds false
//        }
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            debuggable false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            //minifyEnabled true //Normally THIS SHOULDN'T BE HERE
            debuggable true
            //shrinkResources true
            //proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' //Normally THIS SHOULDN'T BE HERE
        }
    }

    dexOptions {
        javaMaxHeapSize "2g"
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    /*
    defaultConfig {
        renderscriptTargetApi 21
        renderscriptSupportModeEnabled true
        renderscriptSupportModeBlasEnabled true
    }
    */
}

ext {
    supportLibVersion = '27.1.1';
    gmsVersion = '15.0.0';
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation files('libs/libadapterinmobi.jar')
//    implementation project(':volley')
    //debugimplementation project(path: ':PG_Edit_SDK', configuration: 'debug')
    //releaseimplementation project(path: ':PG_Edit_SDK', configuration: 'release')

    //implementation('com.twitter.sdk.android:twitter-core:1.7.0@aar') {
    //    transitive = true;
    //}
    implementation 'com.twitter.sdk.android:twitter-core:3.0.0'
    implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }

    //implementation files('libs/InMobi-6.2.3.jar')
    //implementation files('libs/adcolony.jar')
    //implementation files('libs/dagger-2.7.jar')
    //implementation files('libs/javax.inject-1.jar')
    //implementation files('libs/vungle-publisher-adaptive-id-4.0.3.jar')
    //implementation(name: 'AudienceNetwork', ext: "aar")
    //implementation(name: 'PokktSDK_v6.0', ext: "aar")
    //implementation(name: 'unity-ads', ext: "aar")
    //implementation 'com.vmax.android.ads.aar:vmax@aar'
    implementation "com.android.support:appcompat-v7:$supportLibVersion"
    implementation "com.android.support:customtabs:$supportLibVersion"
    implementation "com.android.support:design:$supportLibVersion"
    implementation "com.android.support:cardview-v7:$supportLibVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibVersion"
    implementation "com.android.support:palette-v7:$supportLibVersion"
    implementation "com.android.support:support-v4:$supportLibVersion"

    implementation "com.google.android.gms:play-services-location:15.0.1"
    implementation "com.google.android.gms:play-services-analytics:16.0.3"
    implementation "com.google.android.gms:play-services-ads:15.0.1"
    implementation "com.google.android.gms:play-services-auth:16.0.0"
    implementation "com.google.firebase:firebase-core:16.0.3"
    implementation "com.google.firebase:firebase-messaging:17.3.1"
    implementation "com.google.firebase:firebase-auth:16.0.3"
    implementation "com.google.firebase:firebase-database:16.0.2"
    implementation "com.google.firebase:firebase-appindexing:16.0.1"
    implementation "com.google.android.gms:play-services-measurement-base:16.0.2"
    implementation "com.google.firebase:firebase-config:16.0.0"
    implementation "com.google.firebase:firebase-inappmessaging-display:17.0.1"

    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.30.0'
    implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
    implementation 'com.melnykov:floatingactionbutton:1.3.0'
    implementation 'com.googlecode.mp4parser:isoparser:1.1.22'
    implementation 'me.relex:circleindicator:1.2.1@aar'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.github.bumptech.glide:volley-integration:1.5.0@aar'
    implementation 'com.squareup.okhttp3:okhttp:3.5.0'
    implementation 'com.mixpanel.android:mixpanel-android:4.9.8'
    implementation 'com.flurry.android:analytics:6.4.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.0.4'
    implementation 'com.danikula:videocache:2.7.0'
    //implementation 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'

    implementation 'com.inmobi.monetization:inmobi-ads:7.0.2'

    implementation group: 'commons-io', name: 'commons-io', version: '2.5'
}

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

1 个答案:

答案 0 :(得分:0)

此错误似乎是与您要在Firebase中添加的插件有关的问题。

我尝试将play-services-vision与firebase-analytics结合使用,但遇到相同的错误。有时,它会卡在版本检查中,如果没有最新版本的插件(play-services-vision),它就不会构建。

implementation 'com.google.android.gms:play-services-vision:20.1.2' // was 17.0.0
implementation 'com.google.firebase:firebase-analytics:17.5.0'

您可以根据需要禁用它,但是始终尝试使用最新版本的插件。