Gradle游戏服务评估基础问题

时间:2018-07-16 15:19:10

标签: android firebase gradle android-gradle

当我尝试使用Firebase动态链接时遇到问题。仅当我将该库添加到依赖项时,问题才会出现,但是如果我将其删除,则一切正常:

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

我到处都看过相同问题的不同stackoverflow问题,但找不到任何可行的解决方案。它要么给我上面的错误,要么不编译(同一模块使用两次或类似)。我也曾尝试升级到最新版本,但没有运气。

我的依赖项:

def support_library_version = '27.0.2'
def firebase_and_play_services_version = '15.0.0'
def firebase_version = '15.0.0'
def retrofitVersion = '2.4.0'
def jacksonVersion = '2.9.2'
def daggerVersion = '2.16'

dependencies {
    implementation 'org.slf4j:slf4j-api:1.7.13'
    implementation group: 'com.gimbal.android.v3', name: 'gimbal-sdk', version: '3.2.1'
    implementation group: 'com.gimbal.android.v3', name: 'gimbal-slf4j-impl', version: '3.2.1'

    implementation 'com.google.android:flexbox:0.3.0'

    implementation "com.android.support:design:$support_library_version"
    implementation "com.android.support:cardview-v7:$support_library_version"
    implementation "com.android.support:customtabs:$support_library_version"
    implementation "com.android.support:appcompat-v7:$support_library_version"
    implementation "com.android.support:support-v13:$support_library_version"
    implementation "com.android.support:support-v4:$support_library_version"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    implementation "com.google.android.gms:play-services-gcm:$firebase_and_play_services_version"
    implementation "com.google.android.gms:play-services-analytics:$firebase_and_play_services_version"
    implementation "com.google.android.gms:play-services-location:$firebase_and_play_services_version"
    implementation "com.google.android.gms:play-services-maps:$firebase_and_play_services_version"
    implementation "com.google.android.gms:play-services-ads:$firebase_and_play_services_version"

    implementation "com.google.firebase:firebase-perf:$firebase_version"
    implementation "com.google.firebase:firebase-config:$firebase_version"
    implementation "com.google.firebase:firebase-core:$firebase_version"
    implementation "com.google.firebase:firebase-dynamic-links:$firebase_version"

    implementation 'com.google.maps.android:android-maps-utils:0.3.4'

    implementation "com.google.dagger:dagger:$daggerVersion"
    implementation "com.google.dagger:dagger-android:$daggerVersion"
    kapt "com.google.dagger:dagger-compiler:$daggerVersion"
    kapt "com.google.dagger:dagger-android-processor:$daggerVersion"

    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-jackson:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:2.4.0"

    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
    implementation('com.github.ihsanbal:LoggingInterceptor:2.0.5') {
        exclude group: 'org.json', module: 'json'
    }
    implementation "com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
    implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
    implementation "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"

    //--- RxJava ---//
    implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'

    compileOnly 'javax.annotation:jsr250-api:1.0'

    implementation 'android.arch.persistence.room:runtime:1.0.0'
    kapt "android.arch.persistence.room:compiler:1.0.0"
    implementation 'com.birbit:android-priority-jobqueue:2.0.1'
    implementation 'oauth.signpost:signpost-core:1.2.1.2'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
        transitive = true
    }
    kapt 'org.androidannotations:androidannotations:4.4.0'
    implementation 'org.androidannotations:androidannotations-api:4.4.0'

    implementation 'com.pacioianu.david:ink-page-indicator:1.2.0'
    implementation 'com.sothree.slidinguppanel:library:3.2.1'
    implementation 'me.grantland:autofittextview:0.2.1'
    implementation 'com.facebook.android:facebook-android-sdk:4.28.0'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'net.danlew:android.joda:2.9.4.1'
    implementation 'com.jakewharton:process-phoenix:1.0.2'
    implementation 'com.github.chrisbanes:PhotoView:1.3.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

我还更新了根build.gradle

buildscript {
    ext.kotlin_version = '1.2.51'

    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.0.2'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'

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

2 个答案:

答案 0 :(得分:2)

我能够使用27.1.1版的支持库以及下面显示的G​​oogle Play和Firebase库在测试版本中重现您的错误。更新到最新版本(如图所示)解决了该问题。我不知道这是否与您使用的其他库产生冲突。

implementation "com.google.android.gms:play-services-gcm:15.0.1"
implementation "com.google.android.gms:play-services-analytics:16.0.1"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-maps:15.0.1"
implementation "com.google.android.gms:play-services-ads:15.0.1"

implementation "com.google.firebase:firebase-perf:16.0.0"
implementation "com.google.firebase:firebase-config:16.0.0"
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-dynamic-links:16.0.1"

答案 1 :(得分:1)

您需要将Firebase依赖项更新到最新版本,然后从Firebase site中进行检查。

  

如果您的应用依赖于   com.google.firebase:firebase-core:15.0.0以及任何   以下库:

com.google.android.gms:play-services-analytics
com.google.android.gms:play-services-appinvite
com.google.android.gms:play-services-tagmanager
com.google.firebase:firebase-analytics
com.google.firebase:firebase-crash
com.google.firebase:firebase-dynamic-links
com.google.firebase:firebase-messaging
     

您需要将后一个依赖项的版本更新为   15.0.2。这解决了3.3.0版Google Services Gradle插件报告以下问题:库   com.google.android.gms:play-services-measurement-base正在   在[[15.0.0,15.0.0],   [15.0.2,15.0.2]],但解析为15.0.2 ...

来自firebase.google.com