Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove specific permission when build Android app with gradle?

Recently Google auto merge permission from Google Service to final release apk. Some one ask here Why are permissions being automatically added to my AndroidManifest when including Google Play Services library

My problem is some permission don't need and I don't want some sensitive permission in my app. So how to remove permission like android.permission.ACCESS_COARSE_LOCATION ? With gradle build, I don't want to disable Manifest Merger. I read some where that can config Merger to remove permission from external lib, but I can't find how to do it.

like image 252
DzungPV Avatar asked Jul 24 '15 17:07

DzungPV


People also ask

How do I remove permission from manifest?

The simple way to remove this type of permission, is by deleting its xml code line from the original Android Manifest file in android/app/src/main .

What is manifest permission in Android?

The Android manifest file helps to declare the permissions that an app must have to access data from other apps. The Android manifest file also specifies the app's package name that helps the Android SDK while building the app.


1 Answers

Add attribute tools:node with a value of remove to your manifest:

<manifest ... xmlns:tools="http://schemas.android.com/tools">     ...     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" tools:node="remove" />     ... </manifest> 

See http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-tools:node-markers

Don't forget to add the tools namespace to the root element of your manifest.

like image 152
Johan Stuyts Avatar answered Sep 23 '22 17:09

Johan Stuyts