我有一个具有以下结构的库项目:
<activity android:name="com.comp.package.activities.A1">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.comp.package.activities.A2">
</activity>
<activity android:name="com.comp.package.activities.A3">
</activity>
<activity android:name="com.comp.package.activities.A4">
</activity>
在app项目中,我希望合并后的清单为:
<activity android:name="com.comp.package.activities.A2">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.comp.package.activities.A1">
</activity>
<activity android:name="com.comp.package.activities.A3">
</activity>
<activity android:name="com.comp.package.activities.A4">
</activity>
是否可以使用清单合并功能实现此目的?
如果我试图
<activity android:name="com.comp.package.activities.A2">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
在应用项目的基本清单文件中,我收到以下错误。
Trying to merge incompatible /manifest/application/activity[@name=com.comp.package.activities.A2] element:
<activity
@android:name="com.comp.package.activities.A2">
-- <intent-filter>
-- <action
-- @android:name="android.intent.action.MAIN">
<activity
@android:name="com.comp.package.activities.A2">
++</activity>
++(end reached)
答案 0 :(得分:9)
更改耗材app / lib中的AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
<activity android:name="com.comp.package.activities.A2">
要:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
...
<activity android:name="com.comp.package.activities.A2"
tools:merge="override">