<uses-sdk>

Google Play uses the <uses-sdk> attributes declared in your app manifest to filter your app from devices that don't meet its platform version requirements. Before setting these attributes, make sure that you understand Google Play filters.

syntax:
<uses-sdk android:minSdkVersion="integer"
          android:targetSdkVersion="integer"
          android:maxSdkVersion="integer" />
contained in:
<manifest>
description:

Lets you express an application's compatibility with one or more versions of the Android platform by means of an API level integer. The API level expressed by an application is compared to the API level of a given Android system, which can vary among different Android devices.

Despite its name, this element is used to specify the API level, not the version number of the software development kit (SDK) or Android platform. The API level is always a single integer. You can't derive the API level from its associated Android version number. For example, it isn't the same as the major version or the sum of the major and minor versions.

Also read the document about versioning your applications.

attributes:
android:minSdkVersion
An integer designating the minimum API level required for the application to run. The Android system prevents the user from installing the application if the system's API level is lower than the value specified in this attribute. Always declare this attribute.

Caution: If you don't declare this attribute, the system assumes a default value of "1", which indicates that your application is compatible with all versions of Android. If it isn't, and you didn't declare the proper minSdkVersion, then when installed on a system with an incompatible API level, the application crashes during runtime when attempting to access the unavailable APIs. For this reason, be certain to declare the appropriate API level in the minSdkVersion attribute.

android:targetSdkVersion
An integer designating the API level that the application targets. If not set, the default value equals that given to minSdkVersion.

This attribute informs the system that you have tested against the target version, and the system doesn't enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).

As Android evolves with each new version, some behaviors and even appearances might change. However, if the API level of the platform is higher than the version declared by your app's targetSdkVersion, the system can enable compatibility behaviors so that your app continues to work the way you expect. You can disable such compatibility behaviors by specifying targetSdkVersion to match the API level of the platform on which it's running.

For example, setting this value to "11" or higher lets the system apply the Holo default theme to your app when running on Android 3.0 or higher and also disables screen compatibility mode when running on larger screens, because support for API level 11 implicitly supports larger screens.

There are many compatibility behaviors that the system can enable based on the value you set for this attribute. Several of these behaviors are described by the corresponding platform versions in the Build.VERSION_CODES reference.

To maintain your application along with each Android release, increase the value of this attribute to match the latest API level, then thoroughly test your application on the corresponding platform version.

Introduced in: API level 4

android:maxSdkVersion
An integer designating the maximum API level on which the application is designed to run.

In Android 1.5, 1.6, 2.0, and 2.0.1, the system checks the value of this attribute when installing an application and when re-validating the application after a system update. In either case, if the application's maxSdkVersion attribute is lower than the API level used by the system itself, then the system doesn't let the application install. In the case of re-validation after system update, this effectively removes your application from the device.

To illustrate how this attribute can affect your application after system updates, consider the following example:

An application declaring maxSdkVersion="5" in its manifest is published on Google Play. A user whose device is running Android 1.6 (API level 4) downloads and installs the app. After a few weeks, the user receives an over-the-air system update to Android 2.0 (API level 5). After the update is installed, the system checks the application's maxSdkVersion and successfully re-validates it.

The application functions as normal. However, some time later, the device receives another system update, this time to Android 2.0.1 (API level 6). After the update, the system can no longer re-validate the application because the system's own API level (6) is now higher than the maximum supported by the application (5). The system prevents the application from being visible to the user, in effect removing it from the device.

Warning: We don't recommend declaring this attribute. First, there is no need to set the attribute as a means of blocking deployment of your application onto new versions of the Android platform as they are released. By design, new versions of the platform are fully backward-compatible. Your application works properly on new versions, provided it uses only standard APIs and follows development best practices. Second, in some cases declaring the attribute can result in your application being removed from users' devices after a system update to a higher API level. Most devices on which your application is likely to be installed receive periodic system updates over the air, so consider their effect on your application before setting this attribute.

Introduced in: API level 4

Some versions of Android (beyond Android 2.0.1) don't check or enforce the maxSdkVersion attribute during installation or re-validation. Google Play continues to use the attribute as a filter, however, when presenting users with applications available for download.
introduced in:
API level 1

What is API level?

API level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform.

The Android platform provides a framework API that applications can use to interact with the underlying Android system. The framework API consists of:

  • A core set of packages and classes
  • A set of XML elements and attributes for declaring a manifest file
  • A set of XML elements and attributes for declaring and accessing resources
  • A set of intents
  • A set of permissions that applications can request, as well as permission enforcements included in the system

Each successive version of the Android platform can include updates to the Android application framework API that it delivers.

Updates to the framework API are designed so that the new API remains compatible with earlier versions of the API. That is, most changes in the API are additive and introduce new or replacement functionality. As parts of the API are upgraded, the older replaced parts are deprecated but aren't removed, so that existing applications can still use them.

In a very small number of cases, parts of the API are modified or removed, although typically such changes are only needed to support API robustness and application or system security. All other API parts from earlier revisions are carried forward without modification.

The framework API that an Android platform delivers is specified using an integer identifier called API level. Each Android platform version supports exactly one API level, although support is implicit for all earlier API levels (down to API level 1). The initial release of the Android platform provided API level 1, and subsequent releases have incremented the API level.

The following table specifies the API level supported by each version of the Android platform. For information about the relative numbers of devices that are running each version, see the Distribution dashboard.

Platform VersionAPI levelVERSION_CODENotes
Android 14 API 33 → Beta 2 UPSIDE_DOWN_CAKE Platform Highlights
Android 13 33 TIRAMISU Platform Highlights
Android 12 32 S_V2 Platform Highlights
31 S Platform Highlights
Android 11 30 R Platform Highlights
Android 10 29 Q Platform Highlights
Android 9 28 P Platform Highlights
Android 8.1 27 O_MR1 Platform Highlights
Android 8.0 26 O Platform Highlights
Android 7.1.1
Android 7.1
25 N_MR1 Platform Highlights
Android 7.0 24 N Platform Highlights
Android 6.0 23 M Platform Highlights
Android 5.1 22 LOLLIPOP_MR1 Platform Highlights
Android 5.0 21 LOLLIPOP
Android 4.4W 20 KITKAT_WATCH KitKat for Wearables Only
Android 4.4 19 KITKAT Platform Highlights
Android 4.3 18 JELLY_BEAN_MR2 Platform Highlights
Android 4.2, 4.2.2 17 JELLY_BEAN_MR1 Platform Highlights
Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights
Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights
Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH
Android 3.2 13 HONEYCOMB_MR2
Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights
Android 3.0.x 11 HONEYCOMB Platform Highlights
Android 2.3.4
Android 2.3.3
10 GINGERBREAD_MR1 Platform Highlights
Android 2.3.2
Android 2.3.1
Android 2.3
9 GINGERBREAD
Android 2.2.x 8 FROYO Platform Highlights
Android 2.1.x 7 ECLAIR_MR1 Platform Highlights
Android 2.0.1 6 ECLAIR_0_1
Android 2.0 5 ECLAIR
Android 1.6 4 DONUT Platform Highlights
Android 1.5 3 CUPCAKE Platform Highlights
Android 1.1 2 BASE_1_1
Android 1.0 1 BASE

Uses of API level in Android

The API level identifier serves a key role in helping ensure the best possible experience for users and application developers:

  • It lets the Android platform describe the maximum framework API revision that it supports.
  • It lets applications describe the framework API revision that they require.
  • It lets the system negotiate the installation of applications on the user's device so that version-incompatible applications aren't installed.

Each Android platform version stores its API level identifier internally, in the Android system itself.

Applications can use a manifest element provided by the framework API—<uses-sdk>—to describe the minimum and maximum API levels under which they are able to run as well as the preferred API level that they are designed to support. The element offers three key attributes: