Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I set for compileSdkVersion, minSdkVersion, and targetSdkVersion?

I am concerned about what should I set the compileSdkVersion, minSdkVersion, and targetSdkVersion to be.

  1. My concern first of all is that if I set the compileSdkVersion to be 23 which is the latest right now, will older device be able to run it?

  2. How do I exactly know what should my minSdkVersion be in order to make sure that phone running lower api or version be unable to access it (I don't want to set the minimum sdk too high because that would block phone that could potentially run the app)?

  3. How should I set my targetSdkVersion?

like image 792
Wowzer Avatar asked Nov 26 '15 22:11

Wowzer


People also ask

What is minSdkVersion and targetSdkVersion in Android?

android:minSdkVersion — Specifies the minimum API Level on which the application is able to run. The default value is "1". android:targetSdkVersion — Specifies the API Level on which the application is designed to run.

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.

What minimum SDK should I use Android?

Override the minimum value of SDK version. minSdkVersion is the minimum version of the Android operating system required to run your application. The Android app must have a minimum SDK version 19 or higher. If you want to support devices below API level 19, you must override minSDK version.


2 Answers

I set the compileSdkVersion to be 23 which is the latest right now, will older device be able to run it?

Yes. compileSdkVersion on its own has nothing to do with what devices can and cannot run your app. Usually, you set this to be the latest version of the Android SDK.

How do I exactly know what should my minSdkVersion be in order to make sure that phone running lower api or version be unable to access it?

Frequently, the development tools will warn you on the fly when you try using something that is newer than your minSdkVersion. You can run a full Lint check to reconfirm periodically.

How should I set my targetSdk?

In the absence of any particular reason to choose something else, I usually pick the latest or next-to-latest value at the time I create my project (e.g., 22 or 23 now). targetSdkVersion helps with backwards compatibility, and usually my description is "it's the version of Android that you were thinking of at the time you were writing the code".

like image 94
CommonsWare Avatar answered Sep 21 '22 12:09

CommonsWare


minSdkVersion: This is the minimum API level your application need to run the app (i.e. if you set it at API level 16 (Jelly Bean) then your app can't run on API level 15 (IceCreamSandwitch)). In fact Google Play will not show your app on the phone running on API level lower than your minSdkVersion API level. Using API level 15 (IceCreamSandwitch) covers more than 90% of Android phone.

targetSdkVersion: API level for which you design your app to run. Recommendation is to use the latest version (at present 26 - O)

compileSdkVersion: API level you want to compile your app (if you use features of API level of 26 then you need to use 26, lower version will give you error). Android supports backward compatibility (i.e. app compiled on 23 can also run on phone having API level 22 or lower). So answer to your first question is YES. Recommendation is to use the latest version (at present 26 - O)

like image 34
Debashis Avatar answered Sep 18 '22 12:09

Debashis