Why Are Permissions Being Automatically Added to My Androidmanifest When Including Google Play Services Library

Why are permissions being automatically added to my AndroidManifest when including Google Play Services library

When you use

compile 'com.google.android.gms:play-services:7.5.0'

This implies you are using every feature of Google Play Services, including location services. If you only need a particular API, you should be using the selective APIs.

In the case of ads, you can use solely:

compile 'com.google.android.gms:play-services-ads:7.5.0'

Google Play Services adding unwanted permissions

Checkout https://developers.google.com/android/guides/setup for information from Google how to set up Play Services. Especially checkout the subsection titled Selectively compiling APIs into your executable. It shows you how to breakdown which services to compile in. You'll probably want to use just the games one:

com.google.android.gms:play-services-games:7.5.0

In addition to using fewer permissions, it'll also reduce your APK size and method count, both good things to do anyways instead of pulling in the whole Play Services library.

What permissions are needed by each Google Play Services component?

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.

Why has the READ_PHONE_STATE permission been added?

I eventually found this, which reports the same issue. One workaround is mentioned in Answer #3, which is to remove the permission "manually" (my assumption is that the permission is only required for very early Android versions, which is OK for me since my minSdk is 16):

<manifest ...
xmlns:tools="http://schemas.android.com/tools"
... >

<uses-permission
android:name="android.permission.READ_PHONE_STATE"
tools:node="remove" />

this permision (android.permission.QUERY_ALL_PACKAGES) was automatically added to Manifest

It is because of target SDK updated to 30, some features (eg: Speech recognition,TTS) works in from android 11 device only after adding following code in our AndroidManifest.xml

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:node="remove" tools:ignore="QueryAllPackagesPermission" />

also android:exported="true" inside <activity>

It is mentioned in here Behavior changes: Apps targeting Android 11

You might have to exclusively declare the tools namespace in the manifest header tag for this to work. xmlns:tools="http://schemas.android.com/tools" so that the header will look like this

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.app">

PlayServices ads library 7.5.0 need WRITE_EXTERNAL_STORAGE permission

This was fixed as part of Google Play services 8.3 - the Maps API (which location relies on) no longer requires the storage permission and no longer adds it via manifest merger.



Related Topics



Leave a reply



Submit