Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which API level to use with Support Library in Android?

I want to create an Android app that can be used on 2.3.3 all the way through to 4.0.3. I want to use the Support Library, so that I can use fragments, etc.

Do I set the build target to API level 10 (2.3.3) or do I set it to 15 (4.0.3)?

like image 614
matt_lethargic Avatar asked Jun 12 '12 12:06

matt_lethargic


People also ask

Which Android API level should I use?

When you upload an APK, it must meet Google Play's target API level requirements. New apps must target Android 12 (API level 31) or higher; except for Wear OS apps, which must target Android 11 (API level 30) or higher.

Should you 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 get Android support library?

Downloading the Support LibrariesStart the android SDK Manager. In the SDK Manager window, scroll to the end of the Packages list, find the Extras folder. Select the Android Support Library item. Click the Install packages button.


2 Answers

The answers here are somewhat misleading, as you don't need to set your targetSdkVersion="15" in order for your application to be used all the way up to version 4.0.3. Setting your minSdkVersion="10" alone will allow you to use your application on all devices running Gingerbread and above.

The targetSdkVersion attribute specifies the API level on which the application is designed to run. Preferably you would want its value to correspond to the most recently released SDK ("15", at the time of this posting). Strictly speaking, however, its value should be given by the largest SDK version number that you have tested your application against.

The benefits of a higher targetSdkVersion is that it will enable you to take advantage of shiny new features in the recently released APIs. For instance, if in this case you didn't set your targetSdkVersion, it would default to your minSdkVersion (which is currently "10"). Because of this, your application won't be able to make use of the new UI themes (i.e. Theme.Holo) introduced in HoneyComb and ICS, and will probably be forced into compatibility mode (which is ugly and makes your app look old and poorly maintained).

like image 138
Alex Lockwood Avatar answered Oct 04 '22 13:10

Alex Lockwood


You should set your build target to 15, but minimum SDK to 10.

This way, the Support Libraries will still work on 10, but with reflection you will also be able to directly access higher API version features if you so wanted.

like image 36
Guykun Avatar answered Oct 04 '22 12:10

Guykun