Android 添加支持库时出现渐变错误

Android 添加支持库时出现渐变错误,android,Android,我正在尝试使用我的应用程序 我的依赖项: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'co

我正在尝试使用我的应用程序

我的依赖项:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:preference-v7:25.4.0'
compile 'com.android.support:preference-v14:25.4.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp3:okhttp:3.9.1'
compile 'com.google.firebase:firebase-ads:11.8.0'
compile 'io.github.kobakei:ratethisapp:1.2.0'
compile 'com.timehop.stickyheadersrecyclerview:library:0.4.3'
compile 'com.github.chrisbanes:PhotoView:2.1.3'
testCompile 'junit:junit:4.12'
}

我新增的内容:

compile 'com.android.support:preference-v7:25.4.0'
compile 'com.android.support:preference-v14:25.4.0'
错误与第一个依赖项有关:

编译'com.android.support:appcompat-v7:25.3.1'

它说:

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。已找到版本25.4.0、25.3.1。示例包括com.android.support:animated vector drawable:25.4.0和com.android.support:cardwiew-v7:25.3.1更少。。。(Ctrl+F1) 有些库、工具和库的组合是不兼容的,或者可能导致bug。其中一个不兼容之处是编译时使用的Android支持库版本不是最新版本(尤其是低于targetSdkVersion的版本)


它准确地告诉了你,好吗

com.android.support:**
应该使用相同的版本

将其更改为:

compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support:preference-v7:25.4.0'
compile 'com.android.support:preference-v14:25.4.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.android.support:support-vector-drawable:25.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp3:okhttp:3.9.1'
compile 'com.google.firebase:firebase-ads:11.8.0'
compile 'io.github.kobakei:ratethisapp:1.2.0'
compile 'com.timehop.stickyheadersrecyclerview:library:0.4.3'
compile 'com.github.chrisbanes:PhotoView:2.1.3'

始终使用/更新相同的支持库版本,以便将代码替换为:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile ('com.android.support:appcompat-v7:25.4.0'){force true}
compile ('com.android.support:design:25.4.0'){force true}
compile ('com.android.support:support-v4:25.4.0'){force true}
compile ('com.android.support:preference-v7:25.4.0'){force true}
compile ('com.android.support:preference-v14:25.4.0'){force true}
compile ('com.android.support:cardview-v7:25.4.0'){force true}
compile ('com.android.support:support-vector-drawable:25.4.0'){force true}
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp3:okhttp:3.9.1'
compile 'com.google.firebase:firebase-ads:11.8.0'
compile 'io.github.kobakei:ratethisapp:1.2.0'
compile 'com.timehop.stickyheadersrecyclerview:library:0.4.3'
compile 'com.github.chrisbanes:PhotoView:2.1.3'
testCompile 'junit:junit:4.12'
}

要获取重复的依赖关系报告,请检查此

,您可以尝试找出引用不同支持库版本的位置,这可以帮助您确定如何修复配置。最新版本为27.1.0。此外,您还可以检查哪个依赖项库使用不同版本的gradlew.bat app:dependentials或./gradlew app:dependentials,具体取决于操作系统是否尝试了clean project?失效缓存/重启?听起来很奇怪,所以我自己用上面写的相同依赖项运行了它。一切正常(除了无法解析photoview,但这无关紧要,所以我将其删除)。重要的是要注意,如果您使用的是libversion25,那么您需要使用compilesdk25,如果是24,那么24也需要使用compilesdk25。。。