android - 所有 com.google.android.gms 库都必须使用完全相同的版本规范吗?

标签 android gradle build android-gradle-plugin build.gradle

我在我的构建等级中收到以下针对 compile 'com.google.android.gms:play-services-analytics:9.2.0' 行的警告消息。这是什么意思?

All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 9.2.0, 8.4.0. Examples include com.google.android.gms:play-services-basement:9.2.0 and com.google.android.gms:play-services-ads:8.4.0 less... (Ctrl+F1) 
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

这是我的应用程序 build.gradle:

plugins {
    id "me.tatarka.retrolambda" version "3.2.5"
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId "com.elgami.customizer"
        minSdkVersion 15
        targetSdkVersion 24

        multiDexEnabled true // Enabling multidex support.
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            //runProguard false
            //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.facebook.android:audience-network-sdk:4.13.0'
    compile 'com.bartoszlipinski:recyclerviewheader2:2.0.1'
    compile 'com.ms-square:etsyblur:0.1.3'
    compile 'com.android.support:appcompat-v7:24.0.0'
    // recyclerview
    compile 'com.android.support:recyclerview-v7:24.0.0'
    // google analytics`
    compile 'com.google.android.gms:play-services-analytics:9.2.0'
    compile 'com.google.android.gms:play-services-appindexing:9.2.0'
    // amazon S3 uploads todo remove (5k methods)
    compile 'com.amazonaws:aws-android-sdk-s3:2.2.18'
    // paypal purchasing todo change to 'compile' (2k more methods..?)
    compile files('libs/PayPalAndroidSDK-2.7.1.jar')

    // Module dependency on ParseLoginUI library sources
    compile project(':ParseLoginUI')

    // Consider using these in future - Wes Feb 2016
    //compile 'com.parse:parseui-login-android:0.0.1'
    //compile 'com.parse:parseui-widget-android:0.0.1'

    // Parse
    compile 'com.parse:parse-android:1.13.0'
    compile 'com.parse:parsetwitterutils-android:1.10.5'
    compile 'com.parse:parsefacebookutils-v4-android:1.10.4@aar'

    // excluding bolts-android because parse-android uses bolts-tasks which conflicts
    // hint: use 'gradlew app:dependencies' to inspect
    compile('com.facebook.android:facebook-android-sdk:4.9.0') {
        exclude module: 'bolts-android'
        exclude module: 'bolts-tasks'
    }

    // butterknife
    compile 'com.jakewharton:butterknife:6.1.0'
    // app rater
    compile files('libs/AppRater.jar')

    // retrofit http api
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
    // reactivex
    compile 'io.reactivex:rxjava:1.1.1'
    compile 'io.reactivex:rxandroid:1.1.0'
    // picasso image loading
    compile 'com.squareup.picasso:picasso:2.5.2'
    // stripe for payment processing
    compile 'com.stripe:stripe-android:1.0.4'
}

项目级 gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

最佳答案

我现在有同样的问题,我将 audience-network-sdk 添加为

compile('com.facebook.android:audience-network-sdk:4.17.0') {
    exclude group: 'com.google.android.gms'
}

目前它不会在 gradle 上显示错误。但我现在没有实现广告,我希望它不会导致运行时错误。

ps:它就像一个魅力

关于android - 所有 com.google.android.gms 库都必须使用完全相同的版本规范吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38206861/

相关文章:

Gradle Findbugs 评估子项目,但不评估具有根任务的根项目

java - 如何使用 pom.xml 将参数传递给 Maven 构建?

java - Android 中的信标 - 教程中出现错误

java - 获取我的 Activity 结果的空数据

Android Studio - 将构建机器的 IP 地址获取到 Android 应用程序中

java - 从 gradle 调用的 Ant sshexec 任务不显示输出

cordova - 无法将 Phonegap Build APK 上传到 play.google - 您上传了一个可调试的 APK 错误

deployment - 构建和部署的区别?

java - 尝试在 Android Studio 中实现 getSharedPreferences 时出现 "cannot resolve method"错误

android - 无法解析符号 'AndroidJUnit4'