我是Android的新手。每次包含依赖项时,都会出现以下错误。我尝试了一些可能的解决方案,但似乎没有任何效果。
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 27.0.2. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:customtabs:27.0.2 less... (Ctrl+F1) Inspection info: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). Issue id: GradleCompatible`
最佳答案
首先,假设您使用的是androidx之前的版本,请确保您所有com.android.support依赖项都共享完全相同的版本。这是要搜索的示例依赖项(列表当然并不完整):
com.android.support:appcompat-v7
com.android.support:support-annotations
com.android.support:design
com.android.support:cardview-v7
com.android.support:recyclerview-v7
com.android.support:gridlayout-v7
com.android.support:support-v4
其次,如果您所有的compat依赖项已经共享相同的版本,并且仅在添加其他已知依赖项时才出现问题:您可以排除其可传递的compat依赖项,例如(build.gradle):
implementation(...) {
exclude module: 'appcompat-v7'
exclude module: 'recyclerview-v7'
exclude module: 'support-v4'
}
或像这样:
implementation(...) {
exclude group: 'com.android.support'
}
第三,如果您不知道哪种依赖会引起麻烦,可以通过查看
./gradlew app:dependencies
生成的树来找到它
关于android - Android appCompat依赖项引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54773774/