我的gradle文件
compileSdkVersion 25
buildToolsVersion "25.0.3"
minSdkVersion 17
targetSdkVersion 25
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:cardview-v7:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
添加'compile com.android.support:cardview-v7:25.4.0
会导致compile 'com.android.support:appcompat-v7:25.3.1'
被修改
``在我的代码中,我想在我的应用中使用CardView
功能,只使用compile 'com.android.support:appcompat-v7:25.3.1'
没有做的工作
我该怎么做才能避免在我的代码中使用彼此冲突的库,这是什么意思?
我在红线上玩鼠标时收到的错误信息
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.4.0, 25.3.1. Examples include com.android.support:cardview-v7:25.4.0 and com.android.support:animated-vector-drawable:25.3.1 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)
答案 0 :(得分:2)
那是因为您要添加的CardView
版本大于您的appcompat
版本。所以为了解决这个问题,你需要使用相同的版本
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'