I'm trying to use a manifest placeholder to remove a uses-permission
node in the AndroidManifest.xml
for release builds with no luck.
build.gradle
buildTypes {
release {
manifestPlaceholders.excludeDebugPermissions = "remove"
}
debug {
manifestPlaceholders.excludeDebugPermissions = "merge"
}
}
AndroidManifest.xml
<uses-permission
android:name="android.permission.SYSTEM_ALERT_WINDOW"
tools:node="${excludeDebugPermissions}" />
It produces an error like this:
Error:Execution failed for task ':app:processDebugManifest'. No enum constant com.android.manifmerger.NodeOperationType.${EXCLUDE_DEBUG_PERMISSIONS}
But using the placeholder anywhere else works properly (the merged manifest is OK and there is no error), e.g.
<uses-permission
android:name="${excludeDebugPermissions}"
tools:node="remove" />
So I suppose the tools:node
attribute doesn't support manifest placeholders and I'm probably going to hack it by substituting the permission name instead of the node marker (merge
/ remove
), but I would prefer to avoid it if possible.
Any advices?
The simplest and cleanest way I found to solve this problem was to create a release-only AndroidManifest file (app/src/release/AndroidManifest.xml
) with the following contents to remove the SYSTEM_ALERT_WINDOW
permission:
<?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-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" tools:node="remove"/>
</manifest>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With