What is Android Target version?

What is Android Target version?

The Target Android Version (also known as targetSdkVersion ) is the API level of the Android device where the app expects to run. Android uses this setting to determine whether to enable any compatibility behaviors – this ensures that your app continues to work the way you expect.

What does targetSdkVersion mean?

android:targetSdkVersion — Specifies the API Level on which the application is designed to run. In some cases, this allows the application to use manifest elements or behaviors defined in the target API Level, rather than being restricted to using only those defined for the minimum API Level.

Which Android API level should I use?

New apps and app updates must target Android 11 (API level 30) or higher; except for Wear OS apps, which must target API level 28 or higher. Starting in August 2022, new apps must target API level 31 (Android 12) or above and adjust for behavioral changes.

What is the compilesdkversion?

The CompileSdkVersionis the version of the SDK platform your app works with for compilation, etc DURING the development process (you should always use the latest) This is shipped with the API version you are using You will see this in your build.gradlefile:

Should I change compilesdkversion 21 to 21?

Changing compileSdkVersionto a higher version would mean you want to use some new APIs that are only included in that particular release. If you don’t plan on using any Lollipop-specific features in your app, then there’s really (usually) no reason to ever set compileSdkVersionto 21.

Could I compile against the latest version of the SDK?

My 2 cents: Compile against any version of the SDK but take care not to call any APIs that your “minimum SDK version” does not support. That means you “could” compile against the latest version of the SDK.

Should the target SDK version be higher than compilesdkversion?

No, targetSdkVersionvery likely will be higher than compileSdkVersionand rightfully so. This means that although you designed an app to target API 16, for example, it still runs fine on API 21 (Lollipop) and you should bump your targetSdkVersionto 21 to indicate it is okay for the Android OS to apply any Lollipop-styles that may exist to your app.