What should I set for compileSdkVersion, minSdkVersion and targetSdkVersion?

My concern is that I have to set compileSdkVersion , minSdkVersion and targetSdkVersion .

  • My concern in the first place is that if I set compileSdkVersion to 23, which is the last one now, can an older device run it?

  • How do I know exactly what my minSdkVersion should do to make sure that a phone running with a lower api or version will not be able to access it (I don’t want to set the minimum sdk too high because it would block the phone that could launch the application)?

  • How do I set targetSdkVersion ?

+6
source share
4 answers

I installed compileSdkVersion as 23, which is the last one now, can an older device run it?

Yes. compileSdkVersion alone has nothing to do with which devices can and cannot run your application. Usually you install the latest version of the Android SDK.

How do I know exactly what should be for my minSdkVersion to make sure that a phone with a lower api or version will not be able to access it?

Often, development tools warn you on the fly when you try to use something newer than your minSdkVersion . You can run a full Lint check to re-verify.

How do I install targetSdk?

In the absence of any specific reason to choose something else, I usually select the last or most recent value at the time of creating my project (for example, 22 or 23 now). targetSdkVersion helps with backward compatibility, and usually my description is "this is the version of Android you were thinking about when you wrote the code."

+9
source

Google has just posted a detailed article about this. Shortly speaking:

compileSdkVersion is your way of telling Gradle which version of the Android SDK to compile. Using the new Android SDK is a requirement to use any of the new APIs added at this level. It should be emphasized that modifying your compileSdkVersion command does not change the behavior of the runtime . Although new compiler warnings / errors may appear when you change your compilation of SDKVersion, your compileSdkVersion is not included in your APK: it is used exclusively during compilation.

If compileSdkVersion installs the latest APIs available to you, minSdkVersion is the bottom line for your application . MinSdkVersion is one of the signals that the Google Play Store uses to determine which of the user's devices the application can be installed on. It also plays an important role during development: by default, lint runs against your project, warning you when you use any APIs above your minSdkVersion, helping you avoid a problem while trying to call an API that does not exist. Checking the version of the system at run time is a common method when using the API only for new versions of the platform.

However, the most interesting of these three is targetSdkVersion. targetSdkVersion is the primary way in which Android provides cutting-edge compatibility without applying behavior changes if the targetSdkVersion update is not updated. This allows you to use the new APIs (how did you update your compileSdkVersion file?) Before working with the behavior changes.

+5
source

Your CompileSDKVersion and your TargetSDKVersion should be the same:

 android { compileSdkVersion 24 buildToolsVersion "24.0.2" defaultConfig { applicationId "com.judeochalifu.dribsndrabs" minSdkVersion 15 targetSdkVersion 24 versionCode 1 versionName "1.0" } 

If you are confused about which version number to use, go to the Android SDK Manager , find the API level that you are using (which should always be the last), and there you will find the version to use (Android 7 (API 24) as at the time of writing) .

enter image description here

As for minSDKVersion , the best place to check which you need to use is to go to the Create New Project window (Android Studio here), Google will help you choose the best one that will be used at the moment:

enter image description here

+3
source

minSdkVersion:. This is the minimum API level that your application needs to run the application (i.e. if you install it at API level 16 (Jelly Bean), then your application will not be able to run at API level 15 (IceCreamSandwitch)). In fact, Google Play will not show your application on an API-level phone below the minSdkVersion API level. Using API level 15 (IceCreamSandwitch) covers more than 90% of Android phones.

targetSdkVersion: The API level for which you plan to run your application. The recommendation is to use the latest version (currently 26 - O)

compileSdkVersion: The API level you want to compile for your application (if you use functions of API level 26, then you need to use 26, a lower version will give you an error). Android supports backward compatibility (i.e. an application compiled on 23 can also work on a phone with API level 22 or lower). Therefore, the answer to your first question: YES. The recommendation is to use the latest version (currently 26 - O)

+2
source

All Articles