tools:replace="android:icon, android:theme"

来源:互联网 发布:java内存泄露场景 编辑:程序博客网 时间:2024/06/06 03:37

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


'tools:replace="android:theme"

'tools:replace="android:label"

'tools:replace="android:icon"


原因:

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 这方法有的版本不适用

阅读全文
0 0