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定爲目前市場上最新或者廣泛流行的高版本便可。性能

相關文章
相關標籤/搜索