Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
116 views
in Technique[技术] by (71.8m points)

java - 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.

question from:https://stackoverflow.com/questions/31616334/how-to-remove-specific-permission-when-build-android-app-with-gradle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.READ_PHONE_STATE" 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...