添加支持库时出现Gradle错误

时间:2018-03-12 18:17:24

标签: android

我正在尝试使用PreferenceFragmentCompat

我的依赖项:

IEnumerable<ISomeThing>

}

我新添加的内容:

var ie = value as IEnumerable<ISomeThing>;    
Debug.Assert(ie != null);
foreach (ISomeThing someThingInstance in ie)

错误与第一个依赖关系有关:

  

编译'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:cardview-v7:25.3.1 less ...(Ctrl + F1)   有些库或工具和库的组合不兼容,或者可能导致错误。一个这样的不兼容性是使用不是最新版本的Android支持库版本(或者特别是低于targetSdkVersion的版本)。

2 个答案:

答案 0 :(得分:0)

它完全告诉你,所有

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'

答案 1 :(得分:-1)

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

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'
}

要获取重复的相关性报告,请检查此SO