Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design support library - Which version to use with SDK v21

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)". 

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'.

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.

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

like image 624
Matthias Preu Avatar asked Oct 04 '15 23:10

Matthias Preu


People also ask

Should I use legacy Android support libraries?

We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well. So all Android apps should now aim to use AndroidX, instead of the old support library.

How do I add the v7 AppCompat support library to my project?

back to the mainwindow, click "appcompat"->"libs" on the top-left project area. Right-click on "android-support-v4", select menuitem "Add as library", change "Add to Module" to "Your-project". Same with "android-support-v7-compat".

Which v7 support libraries are used for modifying UI settings?

v7 Preference Support Library The preference package provides APIs to support adding preference objects, such as CheckBoxPreference and ListPreference , for users to modify UI settings. The v7 Preference library adds support for interfaces, such as Preference. OnPreferenceChangeListener and Preference.


2 Answers

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.

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.

like image 183
phxhawke Avatar answered Sep 20 '22 21:09

phxhawke


You can use one of these:

//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'

The design library has dependency with appcompat-v7 library.
You can't use the v23.0.x version compiling with api 22 (it is the reason of "Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

Also, because the first version of the design library is 22, you can't use compileSdk=21.

like image 32
Gabriele Mariotti Avatar answered Sep 21 '22 21:09

Gabriele Mariotti