AndroidManifest.xml注意事项

1、target SDK version
Android Runtime和Dalvik会根据target SDK version决定是否工做在『兼容模式』下,所谓兼容模式,就是关闭了新版本中各类新机制和体验优化的状态。targetSdkVersion若是设置很低,就等因而关闭了全部高版本的新特性和机制,包括『屏幕自适应』、『硬件加速』。
为了保证各个版本的兼容性,及时使用到新特性,targetSdkVersion因随Android最新版本的发布而持续提升,以保证在各个Android版本的设备上都能得到完整的体验。
Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details
2、<application>中的debuggable=”true”
当debuggable打开时,除了更易暴露在攻击之下,SDK tools(包括ProGuard)也不会进行一些针对发布版本能够进行的优化,好比移除dex包中的代码调试信息(符号名、行号等),移除DEBUG和VERBOSE级别的日志输出。这些对App发布版本的容量和性能都有直接的影响。
Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one
3、 <uses-permission>写在<application>以后
表面上看没有什么问题,但却埋下了一些<application>内部属性正确生效的隐患。
The <application> tag should appear after the elements which declare which version you need, which features you need, which libraries you need, and so on. In the past there have been subtle bugs (such as themes not getting applied correctly) when the <application> tag appears before some of these other elements, so it's best to order your manifest in the logical dependency order
java

 

 

 

 

   咱们常常在开发app的时候在AndroidManifest.xml发现这个警告warining:"Not targeting the latest versions of Android; compatibility modes apply. Consider testing and  updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."android

 

        Android Runtime和Dalvik会根据target SDK version决定是否工做在『兼容模式』下,所谓兼容模式,就是关闭了新版本中各类新机制和体验优化的状态。targetSdkVersion若是设置很低,就等因而关闭了全部高版本的新特性和机制,包括『屏幕自适应』、『硬件加速』。
app

 

        个人理解就是这个警告是在提醒咱们没有匹配使用最新的sdk版本,可能致使app在最新的系统上面没法利用最新的特性或功能,去掉这个警告的办法就是把uses-sdk标签中的android:targetSdkVersion属性改成你电脑上面最新的sdk版本,例如个人电脑上最新的sdk是android4.4,它的版本号是19,那么我应该写成“android:targetSdkVersion="19"”,这样就不会报错了,若是你电脑的sdk是android4.0,那么改成android:targetSdkVersion="14"便可。ide

 

        固然,咱们也能够无视这个警告,毕竟市场上的android系统版本仍是要比开发sdk最新版本慢一段时间的,及时咱们为高版本作了适配,也要等上一段时间才可能装载相应的android高版本手机上,因此咱们能够将android:targetSdkVersion定为目前市场上最新或者广泛流行的高版本便可。性能

相关文章
相关标签/搜索