所有com.android.support库都必须使用确切的版本

时间:2017-03-18 08:27:35

标签: android android-studio android-gradle

我遇到过这个问题

  

所有com.android.support库必须使用完全相同的版本   规范(混合版本可能导致运行时崩溃)。发现   版本24.0.0,23.4.0,23.1.1。例子包括   com.android.support:support-v4:24.0.0和   com.android.support:cardview-v7:23.4.0

我一直在阅读herehere

从我收集的内容中,我可以找到"偏移版本"使用

./gradlew -q dependencies app:dependencies --configuration compile

以上结果导致:

compile - Classpath for compiling the main sources.
+--- project :library
|    \--- com.android.support:support-v4:23.1.1 -> 24.0.0
|         \--- com.android.support:support-annotations:24.0.0
+--- com.google.android.gms:play-services-auth:9.8.0
|    +--- com.google.android.gms:play-services-auth-base:9.8.0
|    |    +--- com.google.android.gms:play-services-base:9.8.0
|    |    |    +--- com.google.android.gms:play-services-basement:9.8.0
|    |    |    |    \--- com.android.support:support-v4:24.0.0 (*)
|    |    |    \--- com.google.android.gms:play-services-tasks:9.8.0
|    |    |         \--- com.google.android.gms:play-services-basement:9.8.0 (*)
|    |    \--- com.google.android.gms:play-services-basement:9.8.0 (*)
|    +--- com.google.android.gms:play-services-base:9.8.0 (*)
|    \--- com.google.android.gms:play-services-basement:9.8.0 (*)
+--- com.facebook.android:facebook-android-sdk:4.13.1
|    +--- com.parse.bolts:bolts-android:1.4.0
|    |    +--- com.parse.bolts:bolts-tasks:1.4.0
|    |    \--- com.parse.bolts:bolts-applinks:1.4.0
|    |         \--- com.parse.bolts:bolts-tasks:1.4.0
|    +--- com.android.support:customtabs:23.4.0
|    |    +--- com.android.support:support-annotations:23.4.0 -> 24.0.0
|    |    \--- com.android.support:support-v4:23.4.0 -> 24.0.0 (*)
|    +--- com.android.support:support-v4:23.4.0 -> 24.0.0 (*)
|    \--- com.android.support:cardview-v7:23.4.0
+--- com.google.code.gson:gson:2.3
+--- com.android.support:appcompat-v7:23.1.1
|    \--- com.android.support:support-v4:23.1.1 -> 24.0.0 (*)
+--- com.google.gms:google-services:3.0.0
+--- com.koushikdutta.ion:ion:2.+ -> 2.1.9
|    +--- com.google.code.gson:gson:2.3
|    \--- com.koushikdutta.async:androidasync:2.1.9
+--- com.ivankocijan:MagicViews:1.0.4
+--- com.nineoldandroids:library:2.4.0
+--- com.android.support:multidex:1.0.0
+--- com.crashlytics.sdk.android:crashlytics:2.6.6
|    +--- io.fabric.sdk.android:fabric:1.3.15
|    +--- com.crashlytics.sdk.android:beta:1.2.3
|    |    \--- io.fabric.sdk.android:fabric:1.3.15
|    +--- com.crashlytics.sdk.android:answers:1.3.11
|    |    \--- io.fabric.sdk.android:fabric:1.3.15
|    \--- com.crashlytics.sdk.android:crashlytics-core:2.3.15
|         +--- io.fabric.sdk.android:fabric:1.3.15
|         \--- com.crashlytics.sdk.android:answers:1.3.11 (*)
+--- com.crashlytics.sdk.android:crashlytics-ndk:1.1.5
|    +--- io.fabric.sdk.android:fabric:1.3.14 -> 1.3.15
|    \--- com.crashlytics.sdk.android:crashlytics-core:2.3.13 -> 2.3.15 (*)
\--- com.google.firebase:firebase-core:9.8.0
     \--- com.google.firebase:firebase-analytics:9.8.0
          +--- com.google.android.gms:play-services-basement:9.8.0 (*)
          +--- com.google.firebase:firebase-common:9.8.0
          |    +--- com.google.android.gms:play-services-basement:9.8.0 (*)
          |    \--- com.google.android.gms:play-services-tasks:9.8.0 (*)
          \--- com.google.firebase:firebase-analytics-impl:9.8.0
               +--- com.google.android.gms:play-services-basement:9.8.0 (*)
               +--- com.google.firebase:firebase-iid:9.8.0
               |    +--- com.google.android.gms:play-services-basement:9.8.0 (*)
               |    \--- com.google.firebase:firebase-common:9.8.0 (*)
               \--- com.google.firebase:firebase-common:9.8.0 (*)

摇篮:

enter image description here

我的问题是。

即使我现在发现错误版本的依赖项,我该如何改变呢?

我尝试使用正确的版本编译它们,但警告仍然存在。

1 个答案:

答案 0 :(得分:2)

您应该使用相同的compileSdkVersionbuildToolsVersion作为支持库 e.g。

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.android.support:palette-v7:24.2.0'
 }

您可以在此处看到支持库,compiledSdkVersionbuildToolsVersion使用相同的版本。试试吧,看看它是否解决了你的问题。