android支持库中的版本冲突

时间:2018-04-21 09:26:21

标签: android

我在build.gradle文件中有这个。 所有支持库版本都设置为25.3.1。 Android工作室仍显示错误:

  

所有com.android.support库必须使用完全相同的版本   规范(混合版本可能导致运行时崩溃)。发现   版本26.1.0,25.3.1,23.4.0。例子包括   com.android.support:customtabs:26.1.0和   com.android.support:animated-vector-drawable:25.3.1 less ...(Ctrl + F1)   有一些库,或工具和库的组合   是不兼容的,或可能导致错误。一个这样的不兼容性是   使用不支持的Android支持库版本进行编译   最新版本(或特别是低于您的版本的版本   targetSdkVersion)。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "com.jeyom.boxthought"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:support-v4:25.3.1'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:cardview-v7:25.3.+'
    implementation 'com.android.support:recyclerview-v7:25.3.+'
    implementation 'com.android.support:design:25.3.1'
    implementation 'com.thebluealliance:spectrum:0.7.1'
    implementation 'com.google.android.gms:play-services-ads:15.0.0'
    testImplementation 'junit:junit:4.12'
}

3 个答案:

答案 0 :(得分:1)

错误是由于库implementation 'com.thebluealliance:spectrum:0.7.1'中的app.gradle造成的。此错误可能是由开发人员使用的依赖项引起的,也可能是第三方库中依赖项之间的冲突

他们正在使用以下依赖项

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:preference-v7:23.4.0'
compile 'com.android.support:support-annotations:23.4.0'
compile 'org.greenrobot:eventbus:3.0.0'

检查相应库的app.gradle

您可以通过将目标版本和编译版本减少到23并将支持库更改为23.2.0来解决此问题。

或尝试使用https://github.com/kizitonwose/colorpreference,它可以是类似的库,并将项目更新为27.1.0。(不确定)

或者完全忽略此警告。

第二个原因可能是

播放服务广告15.0.0是用26.1.0编译的,可能会导致显示此警告。尝试使用10.2.1

答案 1 :(得分:1)

answer解释得非常好。这可能是因为您的某个库在内部使用com.android.support:animated-vector-drawable:25.3.1com.android.support:customtabs:26.1.0,因此您需要使用相同的版本单独指定它们。据我所知,你还需要确保编译版本更高(它是,但以防万一)。我有同样的问题,因为与Glide库发生冲突。由于您没有多个依赖项,因此您可以尝试并尝试删除一些(第三方依赖项)并查看错误是否仍然存在。

答案 2 :(得分:0)

我解决了!!全靠我自己! 就是这样:

您必须将 compileSdkVersiontargetSdkVersion 更改为 26(或更高,如果您愿意)AND

将版本 25 的依赖项更改为版本 26...将它们替换为下面给出的内容:

implementation 'com.android.support:appcompat-v7:26.3.1'
implementation 'com.android.support:cardview-v7:26.3.+'
implementation 'com.android.support:recyclerview-v7:26.3.+'
implementation 'com.android.support:design:26.3.1'

编辑:抱歉,没有看到它已经 3 岁零 3 个月大了……但是遇到了类似的问题,所以只想分享。

相关问题