manifest are merged, so this is not yet supported.
You can archive this by adding a new gradle task to your build.gradle and linking it as a dependency of the processDebugResources and processReleaseResources gradle tasks.
task('removeExtraPermissionsDebug') << { //Input the correct manifest file (could be under 'full' folder). def manifestFile = file("build/intermediates/manifests/full/debug/AndroidManifest.xml") def patternPermissions = Pattern.compile(".+(android\\.permission\\.ACCESS_NETWORK_STATE|android\\.permission\\.WAKE_LOCK).+") def manifestText = manifestFile.getText() def matcherPermissions = patternPermissions.matcher(manifestText) def newManifestText = matcherPermissions.replaceAll("") manifestFile.write(newManifestText) } tasks.whenTaskAdded { task -> if(task.name == 'processDebugResources'){ task.dependsOn 'removeExtraPermissionsDebug' } }
Notes:
If you have custom tastes and build types, consider the names of the tasks you need to attach: process{Flavour}{BuildType}Resources .
You may need to replicate the task to remove permissions when creating the release.
source share