簡體   English   中英

設計支持庫-與SDK v21一起使用的版本

[英]Design support library - Which version to use with SDK v21

我在理解支持庫的版本方案以及何時使用哪個版本方面遇到問題。 目前,我有一個帶有compileSdkVersion 21minSdkVersion 21targetSdkVersion 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匹配,即使targetSdkVersionminSdkVersion較低。 如果要使用設計庫,則需要將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。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM