Manifest值沖突解決方法


FBI Warning:歡迎轉載,但請標明出處:http://blog.csdn.net/codezjx/article/details/38669939,未經本人同意請勿用於商業用途,感謝支持!

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

問題一:

Error:(26, 9) Attribute application@icon value=(@drawable/logo) from AndroidManifest.xml:26:9 Error:(28, 9) Attribute application@theme value=(@style/ThemeActionBar) from AndroidManifest.xml:28:9 is also present at XXXX-trunk:XXXXLib:unspecified:15:9 value=(@style/AppTheme) Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:24:5 to override Error:Execution failed for task ':XXXX:processDebugManifest'. > Manifest merger failed with multiple errors, see logs

原因:
AS的Gradle插件默認會啟用Manifest Merger Tool,若Library項目中也定義了與主項目相同的屬性(例如默認生成的Android:icon和android:theme),則此時會合並失敗,並報上面的錯誤。

解決方法有以下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 (懶人方法)

參考官方介紹:
http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger

問題二:
Library Project里面的BuildConfig.DEBUG永遠都是false。這是Android Studio的一個已知問題,某Google的攻城獅說,Library projects目前只會生成release的包。
Issue 52962: https://code.google.com/p/android/issues/detail?id=52962

解決方法:(某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.
https://gist.github.com/almozavr/d59e770d2a6386061fcb

參考stackoverflow上的這篇帖:
http://stackoverflow.com/questions/20176284/buildconfig-debug-always-false-when-building-library-projects-with-gradle

問題三:
每次保存的時候,每行多余的空格和TAB會被自動刪除(例如結尾、空行的多余空格或TAB)
特別是每次准備提交SVN,Review代碼時候你就蛋疼了,顯示一堆不相關的更改,看的眼花。

解決方法:
Settings->IDE Settings->Editor->Other->Strip trailing spaces on Save->None

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

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM