com.google.android.gsf package couldn't be found

AndroidGoogle Cloud-Messaging

Android Problem Overview


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.

Android Solutions


Solution 1 - Android

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.

Solution 2 - Android

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionbahadir arslanView Question on Stackoverflow
Solution 1 - AndroidthepooshView Answer on Stackoverflow
Solution 2 - AndroidJigar BrahmbhattView Answer on Stackoverflow