46

I have an app, with Push notifications implemented.

I want to understand the reason why we need "GET_ACCOUNTS"(android.permission.GET_ACCOUNTS), while implementing GCM? Some users are raising concerns with this permission. I have used this permission in the manifest as it was given in the official site here.

How safe is this permission? and if I remove this, from my manifest, will the push notifications work?

4
  • Have you tried push notifications without GET_ACCOUNTS permission? It seems that it'd be faster to try it than to ask and wait for a reply. Once you know, please post your results as answer.
    – 323go
    Aug 26, 2013 at 12:40
  • 1
    GET_ACCOUNT is to verify if user synced Google account in mobile, and generate the key value for each user(each Google account). This is required if the device is running a version lower than Android 4.0.4.
    – Brinda K
    Aug 26, 2013 at 12:41
  • Okie.. is there any other way of doing this, other than keeping this in manifest? Aug 26, 2013 at 12:42
  • 1
    For me it works without that permission just fine on any OS. Oct 26, 2013 at 20:40

6 Answers 6

63

It uses an existing connection for Google services. For pre-3.0 devices, this requires users to set up their Google account on their mobile devices. A Google account is not a requirement on devices running Android 4.0.4 or higher.

SO this is the reason for requirement of the permission

<uses-permission android:name="android.permission.GET_ACCOUNTS" />

to read Google account.

Read more about this GCM Overview


Google account login is no longer needed for GCM to work. So you do not need the android.permission.GET_ACCOUNTS permission.

If you are using GCM API with GoogleCloudMessaging.register), you no longer need to configure Google account on any Android version. But if you are using the deprecated library (GCMRegistrar.register), you still need a Google Account on older versions (before ICS).

More details at https://groups.google.com/forum/#!topic/android-gcm/ecG-RfH-Aso. Another similer thread is Why google Account login is required for GCM to work for devices below 4.0.4 OS?

7
  • Okie.. is there any other way of doing this, without giving this in manifest? Aug 26, 2013 at 12:43
  • 5
    @VamsiChalla: All permissions must be in the manifest. However, if your android:minSdkVersion is set to 14 or higher, I would interpret the documentation as meaning that you would not need this permission. Aug 26, 2013 at 12:44
  • No. This task is to be done by Google Services, your application can not varify. And other thing is that when you want to read Accounts in Android, this permission will be required. SO at last you have to add this permission. Although you can add some description about this permission in your info page of application, to be clear with user. Aug 26, 2013 at 12:46
  • Without using get_accounts permission for below android version 4.0.4, the notifications doesnot received or it will crash the app? Oct 16, 2013 at 14:15
  • Please read the answer from Eran. This permission is no longer required on any device. Eran's answer is now the correct one. Aug 27, 2014 at 13:56
14

The GET_ACCOUNTS permission is no longer needed for GCM to work. It used to be required for registration to GCM, but a recent Play Services update stopped using the Google account even on Froyo and Gingerbread. If you are registering to GCM with Play Services (i.e. With GoogleCloudMessaging.register), you no longer need this permission on any Android version. If you are using the deprecated library (GCMRegistrar.register), you still need a Google Account on pre 4.0.4 version, which requires that permission.

Source (posted on android-gcm Google Group by a Google developer) :

Some background:

Froyo and Gingerbread registration is implemented in GoogleServicesFramework, using the Google account for registration. This has resulted in a lot of auth errors for people where the account was not in a good state.

Starting with ICS, GCM doesn't depend or uses the Google account - you can use it before you add an account or without any accounts.

The "Play Services" update is implementing the new scheme on all devices - but it seems a small number of devices have problems with this, we're investigating - but the numbers are far lower than those with the old scheme.

7

As everyone else here has said, GET_ACCOUNT is needed for android devices lower than 4.0.4.

If you are like me and have installed a library that automatically adds this permission but you do not need it to, you can tell the AndroidManifest to remove the permission by adding the permission with the tools:node="remove" attribute.

In your AndroidManifest.xml file, make sure the xmlns:tools attribute it defined in your manifest tag and then add the permission with remove set:

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

  ...

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

  ...

</manifest>

Word of warning that this never actually works for me but I know it has worked for others. If you can see what I might be doing wrong or have any more info about it, please comment!

*Edit: There is a bug report open to get this feature working: https://bugzilla.xamarin.com/show_bug.cgi?id=48153

2
  • Seems to be old post but it was not working for me either. So what I did was after reading the android documentation added this additional property in the user persmission android:maxSdkVersion="SOME NUMBER OF API THAT YOU DO NOT SUPPORT" along with the tools:node="remove". It worked for.
    – Devesh
    Jul 19, 2017 at 18:08
  • @Devesh Nice thanks for the extra info. I also edited my post and added the bug report for this feature.
    – hvaughan3
    Jul 20, 2017 at 16:51
3

when you use

compile 'com.google.android.gms:play-services:7.5.0' add the build.gradle file means GET_ACCOUNT permission added automatically.

  • forexample if developer have to use only admob in project means only specify this permission in build.gradle file compile 'com.google.android.gms:play-services-ads:7.5.0' if have any another clarification see this link https://developers.google.com/android/guides/setup
1

I don't think this is actually the case. I tested it on a freshly factory reset Gingerbread device with a new Gmail account and I could receive GCM messages just fine without that permission. So the documentation is WRONG.

0

GET_ACCOUNT is to verify if user synced Google account in mobile, and generate the key value for each user(each Google account). This is required if the device is running a version lower than Android 4.0.4.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.