Android 添加新的支持库对当前库进行红线批注

Android 添加新的支持库对当前库进行红线批注,android,android-studio,android-support-library,Android,Android Studio,Android Support Library,我的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',

我的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'
被红线分隔 ``在我的代码中,我想在我的应用程序中使用
cardwiew
功能,并且只使用
编译'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.) 

这是因为您正在尝试添加比您的
appcompat
版本更大的
CardView
版本。所以为了解决这个问题,你需要使用相同的版本

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'

所以我需要添加相同的版本和一个不超过我的
appcompat
的版本,只要我想添加新的支持库,对吗?是的,它不应该超过
appcompat
的版本,但是它对安卓生态系统中存在的所有类型的支持库都有效吗?或者假设我想使用v4库,我没有任何问题?