简体   繁体   English

添加依赖项时发生Gradle错误

[英]Gradle error while adding dependencies

I want to add a card view so that I want to add dependencies (got from google search) when the time of adding dependencies 我想添加卡片视图,以便在添加依赖项时添加依赖项(从Google搜索中获取)

   compile 'com.android.support:cardview-v7:21.0.+'

屏幕截图

I am getting gradle error saying that 我收到gradle错误,说

This support library should not use a different version (21) than the compileSdkVersion (23) less... (Ctrl+F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. 该支持库不应使用比compileSdkVersion(23)少的版本(21)...(Ctrl + F1)有些库,工具和库的组合不兼容或可能导致错误。 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.) 一种不兼容的情况是使用不是最新版本的Android支持库版本进行编译(或者特别是低于目标targetSdkVersion的版本)。

Change your CardView dependency to: 将您的CardView依赖项更改为:

compile 'com.android.support:cardview-v7:23.1.1'

You cannot have a different compile SDK version to versions of the support library. 您的编译SDK版本不能与支持库的版本不同。

You used sdk version 23 for your project, but you use version 21 for cardview. 您将sdk版本23用于项目,但将版本21用于cardview。 If you compile with cardview-v7:23 there should not be a problem any more. 如果您使用cardview-v7:23编译,就不会再有问题了。 It is also a good idea to update the support libraries, if this does not help. 如果没有帮助,更新支持库也是一个好主意。

Edit: As I see the picture you posted, you can see that you use 23.1.1 for the other dependencies, but 21.0.+ for the others. 编辑:正如我看到的那样,您可以看到对其他依赖项使用23.1.1 ,对其他依赖项使用21.0.+ Change 21.0.+ to 23.1.1 21.0.+ to 23.1.1更改21.0.+ to 23.1.1

compile 'com.android.support:cardview-v7:23.0.1'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM