简体   繁体   中英

Android support libraries, compile SDK version and minimum SDK version

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM