Android AndroidManifest.xml 覆蓋問題Manifest merger failed (android:icon、android:appComponentFactory)

Android AndroidManifest.xml 覆蓋問題Manifest merger failed

項目引用第三方庫或者本地庫的時候經常遇到AndroidManifest.xml 覆蓋合併等衝突問題:
add 'tools:replace=“android:icon” 、add 'tools:replace=“android:appComponentFactory”
比如1:

Manifest merger failed : Attribute application@icon value=(@drawable/ic_launcher) from AndroidManifest.xml:22:5
is also present at MyApplication:library:unspecified:17:8 value=(@drawable/icon)
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:18:4 to override

這樣可以在app的AndroidManifest.xml中做如下處理:
在manifest節點增加:

xmlns:tools="http://schemas.android.com/tools"

在application節點下增加

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

替換覆蓋icon、 theme處理

比如2:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
	is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:6:5-25:19 to override.

這樣可以在app的AndroidManifest.xml中做如下處理:
在manifest節點增加:

xmlns:tools="http://schemas.android.com/tools"

在application節點下增加

tools:replace="android:appComponentFactory"  
android:appComponentFactory="任意字符"      //兩行都需要

替換覆蓋icon、 theme處理

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章