设计支持库-与SDK v21一起使用的版本 [英] Design support library - Which version to use with SDK v21

查看:80
本文介绍了设计支持库-与SDK v21一起使用的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在理解支持库的版本方案以及何时使用哪个版本方面遇到问题。目前我有一个项目,其中 compileSdkVersion 21 minSdkVersion 21 targetSdkVersion 21 并想使用android设计支持库。
当我使用 com.android.support:design:22.2.0 时,项目会编译,但会收到Gradle警告:

I have problems to understand the version scheme of the support libraries and when to use which version. Currently I have a project with compileSdkVersion 21, minSdkVersion 21 and targetSdkVersion 21 and want to use the android design support library. When I use com.android.support:design:22.2.0 the project compiles but I get a Gradle warning:

"This support library should not use a different version (22) than the `compileSdkVersion` (21)". 

当我使用 com.android.support:design:23.0.1 我收到一些编译错误,例如:

When I use com.android.support:design:23.0.1 I get some compilation errors like:

"Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

我想只要 compileSdkVersion 较低或相等,我就可以始终使用最高版本的支持库,但这似乎是错误的。

I thought I can use always the highest version of the support libraries as long as the compileSdkVersion is lower or equal, but that seems wrong.

针对API级别21编译时可以使用设计支持库吗?

Can I use the design support library when compiling against API level 21?

推荐答案

支持库应始终匹配 compileSdkVersion ,即使 targetSdkVersion minSdkVersion 较低。如果要使用设计库,则需要将 compileSdkVersion 设置为至少22并使用库版本22.2.0。

Support Library should always match the compileSdkVersion even if the targetSdkVersion or minSdkVersion are lower. If you want to use the design library you will need to set compileSdkVersion to at least 22 and library version 22.2.0.

原因很简单,库ref的版本选择针对其构建的Android SDK版本。如果您尝试使用比 compileSdkVersion 更高级别的支持库,则可能找不到在更高版本中添加的资源。

The reason for that is simple. The version of the library reflects the version of the Android sdk against it was built. If you try to use a higher level version of the support library than the compileSdkVersion it may not find resources that were added in a later version.

这篇关于设计支持库-与SDK v21一起使用的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆