Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android manifest merger fails for receivers with same name but different content

I'm having problem with manifest merger with duplicated receivers but the content is different. I use the following receivers for different API levels, had no issue so far until merger. Build fails due to merger which says

Element receiver#.receivers.UpdateReceiver duplicated with element declared at AndroidManifest.xml:124:9

I don't want to create another receiver and continue with this schema. Is there any way to disable merger for those situations or merge the receivers in one but with the option of enabling action with different intent?

<receiver
    android:name=".receivers.UpdateReceiver"
    android:enabled="@bool/is_api_below_12">
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_REPLACED" />
        <data android:scheme="package" />
    </intent-filter>
</receiver>

<receiver
    android:name=".receivers.UpdateReceiver"
    android:enabled="@bool/is_api_12_and_above">
    <intent-filter>
        <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
    </intent-filter>
</receiver>
like image 897
Orhan Obut Avatar asked Oct 31 '22 21:10

Orhan Obut


1 Answers

perhaps you can set

android {
   useOldManifestMerger true
}

in your build.gradle file and this worked fine in my project you can see more details here

like image 170
Scorpiuszjj Avatar answered Nov 11 '22 04:11

Scorpiuszjj