天天看點

Manifest值沖突解決方法

整理了一些這段時間遇到的常見問題,希望對各位猿們有幫助。。。如果覺得有用就點個贊哦

問題一:

原因: 

解決方法有以下2種: 

方法1:在Manifest.xml的application标簽下添加tools:replace=”android:icon, android:theme”(多個屬性用,隔開,并且記住在manifest根标簽上加入xmlns:tools=”http://schemas.android.com/tools”,否則會找不到namespace哦) 

方法2:在build.gradle根标簽上加上useOldManifestMerger true (懶人方法)

參考官方介紹: 

<a href="http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger" target="_blank">http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger</a>

問題二: 

Library Project裡面的BuildConfig.DEBUG永遠都是false。這是Android Studio的一個已知問題,某Google的攻城獅說,Library projects目前隻會生成release的包。 

解決方法:(某Google的攻城獅推薦的方法) 

Workaround: instaed of BuildConfig.DEBUG create another boolean variable at lib-project’s e.g. BuildConfig.RELEASE and link it with application’s buildType. 

<a href="https://gist.github.com/almozavr/d59e770d2a6386061fcb" target="_blank">https://gist.github.com/almozavr/d59e770d2a6386061fcb</a>

參考stackoverflow上的這篇帖: 

<a href="http://stackoverflow.com/questions/20176284/buildconfig-debug-always-false-when-building-library-projects-with-gradle" target="_blank">http://stackoverflow.com/questions/20176284/buildconfig-debug-always-false-when-building-library-projects-with-gradle</a>

問題三: 

每次儲存的時候,每行多餘的空格和TAB會被自動删除(例如結尾、空行的多餘空格或TAB) 

特别是每次準備送出SVN,Review代碼時候你就蛋疼了,顯示一堆不相關的更改,看的眼花。

解決方法: 

Settings-&gt;IDE Settings-&gt;Editor-&gt;Other-&gt;Strip trailing spaces on Save-&gt;None

問題四: 

編譯的時候,報:Failure [INSTALL_FAILED_OLDER_SDK]。一般是系統自動幫你設定了compileSdkVersion

修改build.gradle下的compileSdkVersion ‘android-L’為compileSdkVersion 19(或者你本機已有的SDK即可)

    本文轉自 一點點征服   部落格園部落格,原文連結:http://www.cnblogs.com/ldq2016/p/7053833.html,如需轉載請自行聯系原作者

繼續閱讀