72

I am trying to use new Google Cloud Messaging system but I have some problems.

I read Getting Started document and reviewed demo app; after that I applied requirements to my application then I created a new virtual device with API 16.

But when I try to register my device to GCM, it fails because of this line:

GCMRegistrar.checkDevice(getApplicationContext()); 

In logcat I see these errors:

07-05 07:06:31.925: E/AndroidRuntime(691): FATAL EXCEPTION: main
07-05 07:06:31.925: E/AndroidRuntime(691): java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf
07-05 07:06:31.925: E/AndroidRuntime(691):  at com.google.android.gcm.GCMRegistrar.checkDevice(GCMRegistrar.java:83)
07-05 07:06:31.925: E/AndroidRuntime(691):  at aero.tav.mobile.genel$4.onClick(genel.java:201)
07-05 07:06:31.925: E/AndroidRuntime(691):  at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
07-05 07:06:31.925: E/AndroidRuntime(691):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 07:06:31.925: E/AndroidRuntime(691):  at android.os.Looper.loop(Looper.java:137)
07-05 07:06:31.925: E/AndroidRuntime(691):  at android.app.ActivityThread.main(ActivityThread.java:4745)
07-05 07:06:31.925: E/AndroidRuntime(691):  at java.lang.reflect.Method.invokeNative(Native Method)
07-05 07:06:31.925: E/AndroidRuntime(691):  at java.lang.reflect.Method.invoke(Method.java:511)
07-05 07:06:31.925: E/AndroidRuntime(691):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-05 07:06:31.925: E/AndroidRuntime(691):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-05 07:06:31.925: E/AndroidRuntime(691):  at dalvik.system.NativeStart.main(Native Method)

I had added gcm.jar to my class path; I don't know what is wrong.

8
  • 6
    are you using the emulator? if so is it the Google API emulator? if not that's your problem
    – thepoosh
    Jul 5, 2012 at 7:16
  • 2
    is it the Google API emulator?
    – thepoosh
    Jul 5, 2012 at 7:17
  • 2
    I checked it now, i think it is not, it is Android 4.1 API 16. There were two different emulators for API 16. Which one should i use? Jul 5, 2012 at 7:17
  • 3
    the one that has the Google API, the target name should be Google APIs (Google Inc).
    – thepoosh
    Jul 5, 2012 at 7:20
  • I created one as you suggested now and trying again. Jul 5, 2012 at 7:21

2 Answers 2

140

it seems to me like you're using the wrong emulator.

The default emulator uses a regular Android emulator that doesn't have any Google packages and can't run all sorts of things like maps, c2dm and all sorts of stuff like that.

what you want to do, is create a new emulator that can support the Google APIs.

then, when you run the project, choose the emulator that runs the target name Google APIs (Google Inc).

good luck.

1
11

It's probably running on a device that doesn't support GCM, so your call to GCMRegistrar.checkDevice( this ); is throwing an exception. Check your logcat to be sure.

If you're testing it on an emulator, make sure you have the emulator set up to use Google APIs. When you create the emulator, the create new AVD window has a "Target" box. Select something in that box that says "Google APIs".

enter image description here

0

Your Answer

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

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