Search code examples
androidgroovyandroid-manifestmanifest-merging

Android manifest merge dropping attribute


I am using groovy to generate a partial manifest that contains intent filter declarations for app links from my build config files. The merged manifest found in the apk looks as expected but with one issue: the attribute android:debuggable is getting dropped despite being set in build.gradle. If I remove the partial manifest and rebuild the apk, android:debuggable="true" will be set as expected.

my main manifest looks like:

<manifest package="com.app.myapp"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:installLocation="auto">

        <application
        android:name="MyApp"
        tools:replace="android:theme, android:label, android:allowBackup">

        </application>
</manifest>

and my generate partial manifest looks like:

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.app.myapp" xmlns:android="http://schemas.android.com/apk/res/android">
        <application
                android:name="MyApp">
                <activity android:name=".activity.MyActivity">
                        <intent-filter android:autoVerify="true">
                                <action android:name="android.intent.action.VIEW"/>
                                <category android:name="android.intent.category.BROWSABLE"/>
                                <category android:name="android.intent.category.DEFAULT"/>

                        </intent-filter>
                </activity>
        </application>
</manifest>

and in build.gradle file debuggable true is set.

The attribute android:debuggable is getting dropped from the merged manifest found in the apk, what can I do to ensure that it is set correctly without adding it in the partial manifest (I don't know it at gradle sync time when the script runs and don't want to hardcode it to true)?


Solution

  • After removing the android:name attribute from the application node of the partial manifest file, the merge occurs correctly.

    The partial manifest that works:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest package="com.app.myapp" xmlns:android="http://schemas.android.com/apk/res/android">
            <application>
                    <activity android:name=".activity.MyActivity">
                            <intent-filter android:autoVerify="true">
                                    <action android:name="android.intent.action.VIEW"/>
                                    <category android:name="android.intent.category.BROWSABLE"/>
                                    <category android:name="android.intent.category.DEFAULT"/>
    
                            </intent-filter>
                    </activity>
            </application>
    </manifest>