With new gradle dependencies there are situations where you might need to directly affect the manifest using the android manifest "tools", eg to remove the AD_ID permission. Currently any permissions added to the custom AndroidManifest.xml are removed when merged with packages into the app descriptor.
Reproduce
Steps to reproduce:
apm generate config android
Edit AndroidManifest.xml and add a tools remove node:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
<application>
<meta-data android:name="android.max_aspect" android:value="3.0" />
<meta-data android:name="android.notch_support" android:value="true"/>
</application>
</manifest>
Run generation and the remove node won't be in the app descriptor:
<android>
<containsVideo>true</containsVideo>
<manifestAdditions><![CDATA[<manifest android:installLocation="auto" >
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Optional: AUTO START -->
<!-- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> -->
<!-- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> -->
<!-- To control the screen brightness setting -->
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<application>
<meta-data android:name="android.max_aspect" android:value="3.0"/>
<meta-data android:name="android.notch_support" android:value="true"/>
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ASDFASDF"/>
<meta-data android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING" android:value="true"/>
<!-- AUTO START and ALARM MANAGER -->
<receiver android:name="com.distriqt.extension.application.receivers.ApplicationStartupReceiver" android:enabled="true" android:exported="false" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
<!-- ALARM MANAGER -->
<receiver android:name="com.distriqt.extension.application.alarms.AlarmReceiver" android:enabled="true" android:exported="false"/>
<activity android:name="com.distriqt.extension.application.alarms.AlarmActivity" android:exported="false" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<!-- SETTINGS -->
<activity android:name="com.distriqt.extension.application.settings.SettingsActivity" android:exported="false" android:label="Settings"/>
<activity android:name="com.distriqt.core.auth.AuthorisationActivity" android:exported="false" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
</application>
</manifest>
]]></manifestAdditions>
</android>
Expected
We need to be able to automatically add the xmlns:tools="http://schemas.android.com/tools" schema and pass through remove nodes. To give:
<android>
<containsVideo>true</containsVideo>
<manifestAdditions><![CDATA[<manifest android:installLocation="auto" xmlns:tools="http://schemas.android.com/tools" >
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/>
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Optional: AUTO START -->
<!-- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> -->
<!-- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> -->
<!-- To control the screen brightness setting -->
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<application>
<meta-data android:name="android.max_aspect" android:value="3.0"/>
<meta-data android:name="android.notch_support" android:value="true"/>
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ASDFASDF"/>
<meta-data android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING" android:value="true"/>
<!-- AUTO START and ALARM MANAGER -->
<receiver android:name="com.distriqt.extension.application.receivers.ApplicationStartupReceiver" android:enabled="true" android:exported="false" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
<!-- ALARM MANAGER -->
<receiver android:name="com.distriqt.extension.application.alarms.AlarmReceiver" android:enabled="true" android:exported="false"/>
<activity android:name="com.distriqt.extension.application.alarms.AlarmActivity" android:exported="false" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<!-- SETTINGS -->
<activity android:name="com.distriqt.extension.application.settings.SettingsActivity" android:exported="false" android:label="Settings"/>
<activity android:name="com.distriqt.core.auth.AuthorisationActivity" android:exported="false" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
</application>
</manifest>
]]></manifestAdditions>
</android>
With new gradle dependencies there are situations where you might need to directly affect the manifest using the android manifest "tools", eg to remove the AD_ID permission. Currently any permissions added to the custom AndroidManifest.xml are removed when merged with packages into the app descriptor.
Reproduce
Steps to reproduce:
Edit
AndroidManifest.xmland add a tools remove node:Run generation and the remove node won't be in the app descriptor:
Expected
We need to be able to automatically add the
xmlns:tools="http://schemas.android.com/tools"schema and pass through remove nodes. To give: