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?
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.
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.
Related
In an Android application,
I have changed the CompileSdkVersion from 25 to 29 while I am using RecyclerView support lib as following:
implementation 'com.android.support:recyclerview-v7:25.3.1'
Now on Sync Gradle, I see the following error:
The suport library should not use a different version
The problem is when I look for recyclerview-v7:29, there is no version 29 available (the latest version is 28)
How can I solve this issue?
remove the dependency implementation 'com.android.support:recyclerview-v7:25.3.1'
remove the recyclerView that you used.
then try to add a new RecyclerView that will promt you to automatically implement dependency
I want to add a card view so that I want to add dependencies (got from google search) when the time of adding dependencies
compile 'com.android.support:cardview-v7:21.0.+'
I am getting gradle error saying that
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. 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.)
Change your CardView dependency to:
compile 'com.android.support:cardview-v7:23.1.1'
You cannot have a different compile SDK version to versions of the support library.
You used sdk version 23 for your project, but you use version 21 for cardview. If you compile with cardview-v7:23 there should not be a problem any more. 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. Change 21.0.+ to 23.1.1
compile 'com.android.support:cardview-v7:23.0.1'
There is one problem in my build.gradle. The error in the gradle is that ( compile 'com.android.support:appcompat-v7:24.0.0-beta1') on this line the error display that (This support library should not use a different version(24 ) then the compile sdk version 23)
Any idea? And I used Android Studio 2.1.2 and the main problem is that in Android studio there is no android support library. pic is below
Your compileSdkVersion is 23 in the build.gradle file but you're trying to use appcompat-v7:24.0.0 which is for API 24, so you should use appcompat-v7:23.x.y for API 23. If you still want to use appcompat-v7:24.0.0 then you should change the compileSdkVersion to 24
You should use this for compileSdkVersion 23:
compile 'com.android.support:appcompat-v7:23.4.0'
and this for compileSdkVersion 24 :
compile 'com.android.support:appcompat-v7:24.0.0'
Edit
If you work on Android Studio, then you probably don't need to worry about the latest version available, it'll let you know about the latest available version.
You can also check the latest versions available for every sdk version here
Yep, they must not be different. Change it to compile 'com.android.support:appcompat-v7:23.4.0'
I have some general questions about the use of support libraries but I can't find good resources to answer them.
Context :
The app I'm working on has a minimum SDK target set to 9. I'm working with support libraries v4 and v7 that I import with gradle using
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
I also declare the version of sdk to compile against and the minimum SDK version with
minSdkVersion 9
compileSdkVersion 22
Now this will compile and build an apk without error. But when I change the compileSDKVersion to 19, I will get a lot of errors such as
Error:(2) Error retrieving parent for item: No resource found that
matches the given name 'android:TextAppearance.Material.Inverse'.
telling me that the SDK I'm compiling with does not contain some resources used by the compatibility libraries, I should instead use previous compatibility libraries.
Questions:
What is the minimum SDK version I can compile against using both v4 and v7 (or what is the minimal SDK version supported by both v4 and v7) ? Is there a way to see all the versions available in the Android Support Repository ?
Is it risky to set the minimum SDK version to 9 and the compileSDKVersion to 22 and use elements provided by the Support library targetting API 22? I mean: may I get runtime exception due to missing classes/resources ?
Is there a way to configure Gradle to show some potential incompatibilities ? I know sometimes I get a compiling error when using methods present in higher API than the minimum one. But does it generalize to xml as well (such as themes or resources) ?
I know that I get compiling errors when a (support) library references a resource that is not present in the compiled SDK. Is there a way to get similar warnings/errors for the minimum SDK as well ?
Sorry if the questions are too vague, let me know if you need some precisions ! If you know interesting resources that might answer part of a question, don't hesitate to share here ;)
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
It happens because the support libraries v22 require API 22.
You can't compile with API 19.
What is the minimum SDK version I can compile against using both v4 and v7 (or what is the minimal SDK version supported by both v4 and v7)
Usually the minSdk is in the name of the library.
It is api4 for the v4 and api7 for the appcompat.
Is there a way to see all the versions available in the Android Support Repository ?
You can check it inside the folder androidsdk\extras\android\m2repository\com\android\support opening the aar file for example.
Is it risky to set the minimum SDK version to 9 and the compileSDKVersion to 22 and use elements provided by the Support library targetting API 22? I mean: may I get runtime exception due to missing classes/resources ?
No if you are using the support libraries v22.
I know that I get compiling errors when a (support) library references a resource that is not present in the compiled SDK. Is there a way to get similar warnings/errors for the minimum SDK as well ?
No for my experience.
There is a general rule.
The library major version number is the minimun compile sdk version.
It means:
support libraries v21.x.x -> requires API 21
support libraries v22.x.x -> requires API 22
support libraries v23.x.x -> requires API 23
I am attempting to use the Support Action Bar. I have followed all the instructions on how to include the support library in Android Studio v 0.3.0. My build.gradle's dependencies look like:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':NineOld')
compile project(':Helpshift')
compile project(':SlidingMenu:library')
compile project(':AmbilWarna')
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
}
When I attempt to use the theme:
android:theme="#android:style/Theme.AppCompat"
Android Studio says it cannot resolve the symbol. I know this used to be an issue, but I believe it was fixed in 0.2.6.
When building the project, I get
Gradle: No resource found that matches the given name (at 'theme' with value '#android:style/Theme.AppCompat').
After I clean the project with the dependencies, I should see the jars in the External Libraries. Correct? At the moment, I only see the support-v4-18.0.0 jar.
Remove the "android:" prefix.
Styles and Themes not included in your minimum API level will not be there.
So if you're minimum API level is 8 (Froyo), then any time you prefix a resource with "android:" it's going to look in the android "res" folder for platform-8 (android-sdk\platforms\android-8\data\res).
Lastly, the main reason why you need to use the AppCompat library is because the "Theme.Holo" does not exist in your platform "res" folder unless you raise your minimum API level to 11 (Honeycomb).