Why does my app say I am requesting permission for Contacts?

∥☆過路亽.° 提交于 2019-12-01 19:46:10

In one of my apps, I faced an issue where I had my app asking for permissions which I never asked for, the reason for that turned out to be the Google play services.

We have to explicitly mention what part of Google play services we need for our app. For example, if we need ads, we need to use

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

and not

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

what happens is then Google play services will ask permission for all the services it caters to even if our app does not require the same.

Please check, https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project and use only what you need and see if that resolves your problem.

In your case I suspect, Google Account Login as the reason for contacts.

Hope this helps. All the best.

Great suggestion from @Natarajan Raman!! I just want to add there is a great article from @CommonsWare, Hey, Where Did These Permissions Come From? explaining this issue.

Quoting from the article:

It is possible that you will find yourself in a situation where you want a dependency but you don’t want the permissions that the dependency wants. You can try to block the permission from the merger process, by having a element in your own manifest (e.g., in the main sourceset) with tools:node="remove":

So if you only face issues with Contacts permission you could add in your Manifest:

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

And the unwanted permission will be removed.

Hope this helps!!!

FIXED!!!

Changed the dependencies to:

    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'

Instead of:

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

Bonus: Also made my app SO much smaller!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!