Android: is there an advantage in compiling the SdkVersion to a lower version than the latest api?

Is there any advantage that the compileSdkVersion parameter in the manifest is less than the last api build number, or should you always install it in the latest api build?

android {
    compileSdkVersion 22

      

When I talk about benefits, I mean application performance, application compilation time, apk size, etc. I'm talking of course about cases where you can install it below - i.e. an app that doesn't use generic transitions or any candy features.

+3


source to share


3 answers


No no.

Also, thanks to commonsware for pointing this out, but there is a difference between compileSdkVersion and targetSdkVersion. See this previous answer on Stackoverflow.

Just don't install it on the latest M Preview right now. Not that you did it, I am just saying this to new Android developers who are reading this. Android M is a preview version and is not meant for apps yet.



If you are just editing the code of an application that someone wrote a couple of years ago and your boss tells you not to spend more time than making small changes, he wants you to do, then you can also stick to that plan and only compile the source api which was originally used.

In addition, there is a case of security checks and certificates. If a government agency or security company hasn't had time to check the latest OS or sdk, you might get stuck compiling only to the latest certified one.

+4


source


No, it doesn't actually make any changes. But I would suggest that you use the latter to compile it just to be sure.



+2


source


First, there is a difference between targetSdkVersion

and compileSdkVersion

.

compileSdkVersion

compileSdkVersion

gives your application access to the latest APIs, styles and themes. You will get a compilation error if you try to use an API introduced in a later version of Android than compileSdkVersion

.

targetSdkVersion

targetSdkVersion

indicates which version of the API your application was tested against.

Targeting an older version includes compatibility behavior so that the application continues to work the same.

Upgrading targetSdkVersion

to a newer version can result in minor behavior changes, so make sure you know the new APIs and properly test your application if you do. For example: a call AlarmManager.set()

when targeting API <19 will schedule the alarm at the exact time, because this is how it worked before. Calling the same method when targeting API 19+ will allow the system to set the alarm delivery time to a few minutes to save battery life, and if you want the exact time, you need to call a new method AlarmManager.setExact()

.

compileSdkVersion

must always be equal to or greater than targetSdkVersion

.

+2


source







All Articles