Gradle Merge Target Filter Categories
With Gradle, is it possible to add <category android:name="android.intent.category.HOME"/>
activity intents in the flavor manifest to the filter ?. My taste manifest contains an activity with the same name as the base manifest, but I am getting the following from lint:Error: Duplicate registration for activity com.xxx.MainActivity [DuplicateActivity]
Also, by ignoring the Lint, I can get the merge, but there are both intent filter blocks from the base and aromatic manifestations as a result of the manifest, instead of a combination of the two.
Gradle version is 0.12+, of which the docs seem to imply that this is possible.
The main manifest contains the following action:
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="com.reveldigital.player.RESTART"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter"/>
</activity>
The taste manifesto contains:
<activity android:name="com.xxx.MainActivity">
<intent-filter>
<action android:name="com.reveldigital.player.RESTART"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</activity>
The result I am getting looks something like this:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="com.reveldigital.player.RESTART"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="com.reveldigital.player.RESTART"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter"/>
</activity>
source to share
In your manifest add the following:
<manifest ...
xmlns:tools="http://schemas.android.com/tools"
>
If all you want to do is replace the action, then in your Flavor manifest add tools: node = "replace" , for example:
<activity android:name=".MainActivity"
tools:node="replace">
<intent-filter>
<action android:name="com.reveldigital.player.RESTART"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</activity>
More details: http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger
source to share