所有android支持库必须使用相同的版本规范

时间:2017-04-09 12:58:52

标签: android gradle android-support-library

我不知道我哪里出错,但这让我说

All com.android.support libraries must use the same exact version specification (mixing versions can lead to runtime crashes.) Found versions 24.0.0,23.2.0 Examples include com.android.support:animated-vector-drawable:24.0.0 and com.android.support:cardview-v7:23.2.0

我的build.gradle是

        apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.example.project"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

allprojects {
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:design:23.2.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'
    compile 'com.android.support:cardview-v7:23.2.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.mani:ThinDownloadManager:1.2.2'
    compile 'net.rdrei.android.dirchooser:library:3.2@aar'
    compile 'com.google.android.gms:play-services:10.2.0'
    compile 'com.onesignal:OneSignal:3.+@aar'

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

它也显示此行中的错误

compile 'com.android.support:appcompat-v7:23.2.0'

我尝试将compileSdkVersion更改为24,但现在似乎没有任何工作。实际上在介绍游戏服务库之前一切正常。

1 个答案:

答案 0 :(得分:2)

此依赖项使用的是com.android.support:animated-vector-drawable版本24.0.0:

compile 'com.google.android.gms:play-services:10.2.0'

这将导致android工作室抱怨它可能导致错误/崩溃,因为所有谷歌库的版本都不匹配。

所以你有2个选择: (我知道这一点)

  1. 将您的compileSdkVersion更改为24并将所有支持库依赖项更改为版本24,以匹配播放服务依赖项:

    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.android.support:recyclerview-v7:24.0.0'
    compile 'com.android.support:cardview-v7:24.0.0'
    
  2. com.google.android.gms:play-services降级为9.4或9.2.1,以便它不会使用版本24的任何内容。这仍然需要对支持库进行微小的更改,从23.2.0到23.0.0

    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:design:23.0.0'
    compile 'com.android.support:recyclerview-v7:23.0.0'
    compile 'com.android.support:cardview-v7:23.0.0'
    compile 'com.google.android.gms:play-services:9.4.0'