Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use manifest placeholders to remove a permission

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?

like image 776
Andrzej Zabost Avatar asked Jul 18 '17 14:07

Andrzej Zabost


1 Answers

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>
like image 148
pho79 Avatar answered Sep 17 '22 16:09

pho79