一般是项目中使用的第三方依赖库中的AndroidManifest.xml中跟当前app的AndroidManifest.xml中有重复的某些属性时AS会提示这个,其实你按照他的提示添加就可以解决了,这里只是记录一下。
比如第三方库中也定义了application@icon application@label属性,则会与你的项目发生冲突。
那么解决的方法就是在你的Application节点中加入tools:replace来表示替换三方库中的相关属性,如下:
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@drawable/box_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:replace="android:icon, android:label">
比如在使用二维码识别的支持库zxing-android-embedded时,需要自定义拍照Activity的屏幕方向,则在AndroidManifest.xml中加入相关的activity节点,并覆盖其属性,xml如下
<!--二维码扫描界面 for zxing-android-embedded-->
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
tools:replace="screenOrientation" />
使用tools:replace需要在manifest根节点加上相关的引用,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.bcoder.app">
接入九游SDK时,在九游SDK的一个.aar文件 AndroidManifest.xml 已经存在 android:name="cn.uc.gamesdk.activity.PullupActivity" 这个节点了。在自己游戏中的 AndroidManifest.xml 文件也需要配置这个节点(配置自己游戏的参数),我们需要将整个节点覆盖掉九游SDK中的整个节点。
<!-- android:taskAffinity 填上游戏的包名,如游戏包名为cn.uc.gamesdk.demo,则下面填 cn.uc.gamesdk.demo.diff -->
<!-- data android:scheme 里填上”ng+当前游戏的gameId”,如游戏ID是123456,则填上ng123456 -->
<!-- tools:replace="android:taskAffinity" -->
<!-- tools:node="replace" 代表此节点优先级较高,将替换其它第三方库中的相同节点 -->
<activity
android:name="cn.uc.gamesdk.activity.PullupActivity"
tools:node="replace"
android:theme="@android:style/Theme.Translucent"
android:taskAffinity="com.XXXX.XXXX.aligames.diff"
android:excludeFromRecents="true"
android:label="PullupActivity"
android:launchMode="singleTop"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="ngXXXXXXXXXX" />
</intent-filter>
</activity>