Failed to get API Level 17 Token

I run these commands to get the token:

  InstanceID instanceID = InstanceID.getInstance(getApplicationContext());
  String token = instanceID.getToken(Config.GOOGLE_PROJECT_ID,
                             GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);

But getting this exception:

java.io.IOException: MISSING_INSTANCEID_SERVICE
            at com.google.android.gms.iid.zzc.zza(Unknown Source)
            at com.google.android.gms.iid.zzc.zzb(Unknown Source)
            at com.google.android.gms.iid.zzc.zza(Unknown Source)
            at com.google.android.gms.iid.InstanceID.zzc(Unknown Source)
            at com.google.android.gms.iid.InstanceID.getToken(Unknown Source)
            at autofocus.com.autofocus.activity.ItemListActivity$4.doInBackground(ItemListActivity.java:408)
            at autofocus.com.autofocus.activity.ItemListActivity$4.doInBackground(ItemListActivity.java:398)

Any idea what I'm doing wrong?

+1
source share
2 answers

According to official docs:

https://developers.google.com/android/reference/com/google/android/gms/iid/InstanceID#ERROR_MISSING_INSTANCEID_SERVICE

you get this error because

Tokens cannot be generated. Only devices with Google Play are supported.

Testing on an emulator without using / installing Google Play Services?

+9
source

gapps , genymotion, gapps di Genymotion-ARM-Translation_v1.1 , ,

0

Source: https://habr.com/ru/post/1670492/


All Articles