设计支持库 - SDK v21 使用哪个版本
Design support library - Which version to use with SDK v21
我无法理解支持库的版本方案以及何时使用哪个版本。目前我有一个包含 compileSdkVersion 21
、minSdkVersion 21
和 targetSdkVersion 21
的项目,我想使用 android 设计支持库。
当我使用 com.android.support:design:22.2.0
时,项目编译但我收到 Gradle 警告:
"This support library should not use a different version (22) than the `compileSdkVersion` (21)".
当我使用 com.android.support:design:23.0.1
时,出现一些编译错误,例如:
"Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
我认为只要 compileSdkVersion
低于或等于,我就可以始终使用最高版本的支持库,但这似乎是错误的。
针对 API 级别 21 进行编译时,我可以使用设计支持库吗?
支持库应始终与 compileSdkVersion
匹配,即使 targetSdkVersion
或 minSdkVersion
较低。如果您想使用设计库,您需要将 compileSdkVersion
设置为至少 22 和库版本 22.2.0.
原因很简单。库的版本反映了针对它构建的 Android sdk 的版本。如果您尝试使用比 compileSdkVersion
更高版本的支持库,它可能找不到在更高版本中添加的资源。
您可以使用其中之一:
//You have to use compileSdkVersion=22
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:design:22.2.1'
//You have to use compileSdkVersion=23
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.0.0'
设计库与 appcompat-v7 库有依赖关系。
你不能使用用api 22编译的v23.0.x版本(这是"Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'
.
的原因
另外,因为设计库的第一个版本是22,不能用 compileSdk=21.
我无法理解支持库的版本方案以及何时使用哪个版本。目前我有一个包含 compileSdkVersion 21
、minSdkVersion 21
和 targetSdkVersion 21
的项目,我想使用 android 设计支持库。
当我使用 com.android.support:design:22.2.0
时,项目编译但我收到 Gradle 警告:
"This support library should not use a different version (22) than the `compileSdkVersion` (21)".
当我使用 com.android.support:design:23.0.1
时,出现一些编译错误,例如:
"Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
我认为只要 compileSdkVersion
低于或等于,我就可以始终使用最高版本的支持库,但这似乎是错误的。
针对 API 级别 21 进行编译时,我可以使用设计支持库吗?
支持库应始终与 compileSdkVersion
匹配,即使 targetSdkVersion
或 minSdkVersion
较低。如果您想使用设计库,您需要将 compileSdkVersion
设置为至少 22 和库版本 22.2.0.
原因很简单。库的版本反映了针对它构建的 Android sdk 的版本。如果您尝试使用比 compileSdkVersion
更高版本的支持库,它可能找不到在更高版本中添加的资源。
您可以使用其中之一:
//You have to use compileSdkVersion=22
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:design:22.2.1'
//You have to use compileSdkVersion=23
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.0.0'
设计库与 appcompat-v7 库有依赖关系。
你不能使用用api 22编译的v23.0.x版本(这是"Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'
.
另外,因为设计库的第一个版本是22,不能用 compileSdk=21.