为什么在包含Google Play服务库时,权限会自动添加到我的AndroidManifest中

时间:2021-09-23 21:09:07

I noticed that the following permissions were automatically added when i use the following in my build.gradle file

我注意到当我在build.gradle文件中使用以下内容时,会自动添加以下权限

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

This did not occur with the earlier versions of the play-services. does anyone have a solution to remove these unwanted permissions?

早期版本的播放服务不会出现这种情况。有没有人有解决方案来删除这些不需要的权限?

I am only using the ads function (INTERNET and ACCESSNETWORK_STATE). I got no need for the LOCATION and USE_CREDENTIALS permissions. How do you remove these unwanted permissions?

我只使用广告功能(INTERNET和ACCESSNETWORK_STATE)。我不需要LOCATION和USE_CREDENTIALS权限。你如何删除这些不需要的权限?

I noticed that the 'manifest-merger-xxx-debug-report.txt' file contains the following

我注意到'manifest-merger-xxx-debug-report.txt'文件包含以下内容

 ...<snipped bunch of other merges>
MERGED from com.google.android.gms:play-services-maps:7.5.0:22:5
    android:name
        ADDED from com.google.android.gms:play-services-maps:7.5.0:22:22
uses-permission#android.permission.ACCESS_COARSE_LOCATION
ADDED from com.google.android.gms:play-services-maps:7.5.0:23:5
MERGED from com.google.android.gms:play-services-maps:7.5.0:23:5
MERGED from com.google.android.gms:play-services-maps:7.5.0:23:5
MERGED from com.google.android.gms:play-services-maps:7.5.0:23:5
    android:name
        ADDED from com.google.android.gms:play-services-maps:7.5.0:23:22
uses-feature#0x00020000
ADDED from com.google.android.gms:play-services-maps:7.5.0:24:5
MERGED from com.google.android.gms:play-services-maps:7.5.0:24:5
MERGED from com.google.android.gms:play-services-maps:7.5.0:24:5
MERGED from com.google.android.gms:play-services-maps:7.5.0:24:5
    android:glEsVersion
        ADDED from com.google.android.gms:play-services-maps:7.5.0:25:8
    android:required
        ADDED from com.google.android.gms:play-services-maps:7.5.0:26:8
android:uses-permission#android.permission.READ_EXTERNAL_STORAGE
IMPLIED from AndroidManifest.xml:2:1 reason: com.google.android.gms.maps requested WRITE_EXTERNAL_STORAGE
uses-permission#android.permission.GET_ACCOUNTS
ADDED from com.google.android.gms:play-services-wallet:7.5.0:21:5
    android:name
        ADDED from com.google.android.gms:play-services-wallet:7.5.0:21:22
uses-permission#android.permission.USE_CREDENTIALS
ADDED from com.google.android.gms:play-services-wallet:7.5.0:22:5
    android:name
        ADDED from com.google.android.gms:play-services-wallet:7.5.0:22:22
meta-data#com.google.android.gms.wallet.api.enabled
 ...<snips more lines away>

2 个解决方案

#1


43  

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.

这意味着您正在使用Google Play服务的所有功能,包括位置服务。如果您只需要特定的API,则应该使用选择性API。

In the case of ads, you can use solely:

对于广告,您可以单独使用:

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

#2


16  

You can exclude those auto added permissions if your app feature doesn't require.

如果您的应用功能不需要,您可以排除这些自动添加的权限。

In my case i'm using Google wallet play service 8.3 which adds GET_ACCOUNTS and USE_CREDENTIALS . We don't required user to pick the google account for selecting google wallet.

在我的情况下,我正在使用谷歌钱包播放服务8.3,它增加了GET_ACCOUNTS和USE_CREDENTIALS。我们不要求用户选择谷歌帐户来选择谷歌钱包。

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

tools:node="remove" does the trick when creating the full manifest.

tools:node =“remove”在创建完整清单时起作用。

Look at the Full final AndroidManifest.xml at /build/intermediates/manifest/full/debug

查看/ build / intermediates / manifest / full / debug中的Full final AndroidManifest.xml

#1


43  

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.

这意味着您正在使用Google Play服务的所有功能,包括位置服务。如果您只需要特定的API,则应该使用选择性API。

In the case of ads, you can use solely:

对于广告,您可以单独使用:

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

#2


16  

You can exclude those auto added permissions if your app feature doesn't require.

如果您的应用功能不需要,您可以排除这些自动添加的权限。

In my case i'm using Google wallet play service 8.3 which adds GET_ACCOUNTS and USE_CREDENTIALS . We don't required user to pick the google account for selecting google wallet.

在我的情况下,我正在使用谷歌钱包播放服务8.3,它增加了GET_ACCOUNTS和USE_CREDENTIALS。我们不要求用户选择谷歌帐户来选择谷歌钱包。

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

tools:node="remove" does the trick when creating the full manifest.

tools:node =“remove”在创建完整清单时起作用。

Look at the Full final AndroidManifest.xml at /build/intermediates/manifest/full/debug

查看/ build / intermediates / manifest / full / debug中的Full final AndroidManifest.xml