为什么我的应用显示我正在请求通讯录权限?

5

我有一个表盘应用程序,它显示我正在请求联系人权限...但实际上并没有。我无法弄清楚为什么会这样...

我有应用内计费,并且我访问Google Fit数据...以及Google Analytics。

以下是我的清单中的权限列表:

<!-- Normal Permissions -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="com.android.vending.BILLING" />

    <!-- Dangerous Permissions -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <!-- Permissions required by the wearable app -->
    <uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

这是来自Play商店的此应用程序权限列表:

In-app purchases
Identity
find accounts on the device
Contacts
find accounts on the device
Location
precise location (GPS and network-based)
approximate location (network-based)
Photos/Media/Files
modify or delete the contents of your USB storage
read the contents of your USB storage
Storage
modify or delete the contents of your USB storage
read the contents of your USB storage
Other
receive data from Internet
full network access
view network connections
run at startup
prevent device from sleeping
use accounts on the device

应用程序依赖项:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    wearApp project(':Wearable')
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.support:wearable:1.3.0'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    compile files('libs/httpclient-4.5.1.jar')
    compile files('libs/apache-httpcomponents-httpclient.jar')
    compile files('libs/apache-httpcomponents-httpclient-cache.jar')
    compile files('libs/apache-httpcomponents-httpcore.jar')
    compile files('libs/apache-httpcomponents-httpmime.jar')
    compile files('libs/GoogleConversionTrackingSdk-2.2.4.jar')
    compile files('libs/feedback_v6.jar')
}

穿戴依赖:
dependencies {
    compile 'com.google.android.support:wearable:1.3.0'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.android.support:support-v13:23.1.0'
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
}

你是否使用了Google Play服务?如果是的话,能否请您发布您的build.gradle依赖项? - Natarajan Raman
已更新应用程序和穿戴设备依赖项... - DeNitE Appz
尝试查找 app/build/outputs/logs/manifest-merger-debug-report.txt,或者发布报告。您将找到哪个权限来自哪个依赖项。 - Aaron He
找到了...但是联系人根本不在里面... - DeNitE Appz
3个回答

9
在我的一个应用程序中,我遇到了一个问题,即我的应用程序要求权限,但我从未请求过该权限,原因是 Google Play 服务。
我们必须明确说明我们的应用程序需要 Google Play 服务的哪个部分。例如,如果我们需要广告,则需要使用

com.google.android.gms:play-services-ads:8.4.0

而不是

com.google.android.gms:play-services:8.4.0

发生的情况是,即使我们的应用程序不需要同样的服务,Google Play服务也会请求所有服务的权限。

请检查https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project,只使用您需要的内容,看看是否解决了您的问题。

在您的情况下,我怀疑Google帐户登录是联系人的原因。

希望这可以帮助您。祝一切顺利。


这非常有道理!感谢您的建议! - DeNitE Appz

6

来自@Natarajan Raman的好建议!我只想补充一下,@CommonsWare有一篇很棒的文章,Hey, Where Did These Permissions Come From?,解释了这个问题。

摘自该文章:

可能会出现这样的情况:您需要一个依赖项,但不希望该依赖项需要的权限。您可以尝试通过在自己的清单中(例如,在主源集中)使用tools:node="remove"的元素来阻止合并过程中的权限:

因此,如果您仅遇到“联系人”权限问题,则可以在清单中添加以下内容:

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

不需要的权限将被删除。

希望这能帮到你!


好的!我会记住的!不过,我已经根据他的建议解决了问题 :-) - DeNitE Appz

0

已修复!!!

将依赖项更改为:

    compile 'com.google.android.gms:play-services-fitness:8.3.0'
    compile 'com.google.android.gms:play-services-wearable:8.3.0'
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    compile 'com.google.android.gms:play-services-appindexing:8.3.0'

改为:

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

额外奖励:还让我的应用程序变得更小了!!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接