问题
As I found out in Why are permissions being automatically added to my AndroidManifest when including Google Play Services library, various Google Play Services components implicitly add permissions to your app starting in Google Play Services 7.5. But obviously not all components require the same permissions - for instance, play-services-games:7.8.0 doesn't require any.
Is there an easy way to tell what permissions will be added by a particular Google Play Services component?
回答1:
Visit $ANDROID_SDK/extras/google/m2repository/com/google/gms
. In there, choose your desired artifact (e.g., play-services-maps
) and version (e.g., 8.1.0
). Open up the AAR in your favorite ZIP utility, and look at the AndroidManifest.xml
file published in there, to see if there are <uses-permission>
elements. Then, open up the POM file, see what dependencies there are, and repeat the process for the AARs for those dependencies.
回答2:
As described in this excellent article, you can see the final manifest file created during the build process here;
app/build/intermediates/manifests/full/debug/AndroidManifest.xml
You can also see a report that shows where every permission comes from;
app/build/outputs/logs/manifest-merger-debug-report.txt
You can use a line like this in your manifest to remove any extra permissions you want (but be careful! you might break functionality);
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove"/>
来源:https://stackoverflow.com/questions/33190205/what-permissions-are-needed-by-each-google-play-services-component