Android:将compileSdkVersion设置为低于最新api的版本是否有优势?

Android:将compileSdkVersion设置为低于最新api的版本是否有优势?

问题描述:

将清单中的compileSdkVersion设置为小于最新的api构建号是否有任何优势,还是应该始终将其设置为最新的api构建?

Is there any advantage to setting the compileSdkVersion in the manifest to less than the latest api build number, or should you always set it to the latest api build?

android {
    compileSdkVersion 22

当我说优势时,我指的是应用程序的性能,应用程序的编译时间,apk的大小等.当然,我说的是您可以的情况>降低它-即不使用共享过渡或棒棒糖任何功能的应用.

When I say advantage I mean in terms of performance of the app, of compile time of the app, of size of the apk etc. I'm speaking, of course, of cases where you can set it lower - i.e. an app that doesn't use shared transitions or any features of lollipop.

不,没有.

此外,还要感谢commonsware指出了这一点,但是compileSdkVersion和targetSdkVersion之间是有区别的.在Stackoverflow上查看此上一个答案.

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

请不要立即将其设置为最新的M预览.不是您这样做,我只是对正在阅读本文的新Android开发人员说这句话. Android M是预览版,尚不适用于生产中的应用.

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

话虽如此,如果您只是编辑某人几年前编写的应用程序的代码,而您的老板告诉您,不要浪费更多的时间,而不必浪费他想要做的微小更改,那么您最好还是坚持该计划,只编译为最初使用的初始api.

That being said, if you're just editing the code of an application that someone wrote a couple of years ago and your boss tells you not to waste more time than you have to on a tiny little change he wants you to make, then you might as well stick to that plan and only compile to the initial api that was originally used.

此外,还存在安全审核和认证的情况.如果政府机构或安全公司没有时间审核OS或SDK的最新版本,则您可能只需要编译为最新认证的版本即可.

Also, there is the case of security audits and certifications. If a government agency or a security company hasn't had the time to audit the latest version of an OS or sdk, then you may be stuck compiling only to the version that was last certified.