5

I'm trying to use the notification in an Android app, I found many tuto but all use the com.google.android.gcm pakage which are deprecated. I see that I have to use the com.google.android.gms.gcm.GoogleCloudMessaging pakage... but I don't succeed to import this package.

  • I already download all the stuff from the SDK manager
  • In the Properties project I chose the Project Build target: Google APIs (17)
  • In the build path I check also the Google APIs.

and I always have the same error: The import com.google.android.gms.gcm.GoogleCloudMessaging cannot be resolved

Did I forget to add a jar or an other file I miss?

thanks

edit: I miss this page with the informations (give in the other discution above) for the setup: http://developer.android.com/google/play-services/setup.html#Setup

I just don't copy the lib of Google Play.

user2571821
  • 71
  • 1
  • 1
  • 3
  • did you added gcm.jar file to your project – vinay kumar Jul 11 '13 at 09:35
  • something I don't understood: I saw many tuto using the com.google.android.gcm.GCMRegistrar package, but here: http://developer.android.com/reference/com/google/android/gcm/GCMRegistrar.html I see that this package is DEPRECATED and that we have to use GoogleCloudMessaging (http://developer.android.com/reference/com/google/android/gms/gcm/GoogleCloudMessaging.html). But when you are in eclipse wile using the GCMRegistrar, you don't have the common warning 'deprecated'. did I miss something? did I just have to use GCMRegistrar? and forget what it is writing on the http://developer.android.com? – user2571821 Jul 11 '13 at 10:08

2 Answers2

6

Whether you added gcm.jar in your project?

Go to Android SDK Manager->Extras->GCM. Downlad it. Go to particular location.

It will contain gcm.jar.Add in your project.

Excellent tutorial is given here

http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

Shadow
  • 6,864
  • 6
  • 44
  • 93
  • 1
    I already have the gcm.jar, but in this one I only have the deprecated class GCMBaseIntentService, GCMBroadcastReceiver,GCMConstants and GCMRegistrar, and it's the GoogleCloudMessaging class I would like to use. – user2571821 Jul 11 '13 at 09:59
  • Add jar in your libs-> Add to build path.it will work. – Shadow Jul 11 '13 at 10:07
  • I have the gcm.jar in the lib folder and in the build path, but in this jar I don't have the GoogleCloudMessaging package (http://developer.android.com/reference/com/google/android/gms/gcm/GoogleCloudMessaging.html), and yes I see that the GCMRegistar class work but I dont understood why here it is write that this class is deprecated (http://developer.android.com/reference/com/google/android/gcm/GCMRegistrar.html) – user2571821 Jul 11 '13 at 12:13
  • I know the tutorial you give, a realy good one – user2571821 Jul 11 '13 at 12:15
  • @Shadow i am trying to create app that work like gmail as the message comes from the server it show it as a notification see this is my question http://stackoverflow.com/questions/18571844/gcm-not-sending-the-notifications/18572611?noredirect=1#comment27328335_18572611 – Developer Sep 02 '13 at 12:36
0

You will need the GCM libraryy to work with GCM. You need to put GCM jar file in your libs folder and then you have to add it in you project. To get GCM library and add it to your project look at this link :

Getting Started with GCM

Vipul Purohit
  • 9,807
  • 6
  • 53
  • 76
  • 1
    I already have the gcm.jar, but in this one I only have the deprecated class GCMBaseIntentService, GCMBroadcastReceiver,GCMConstants and GCMRegistrar, and it's the GoogleCloudMessaging class I would like to use. – user2571821 Jul 11 '13 at 09:58
  • Copy the JAR file in your libs folder. Then right click on GCM jar file and Select Build Path --> Add to BUild path. – Vipul Purohit Jul 11 '13 at 10:18
  • 2
    I have the gcm.jar in the lib folder and in the build path, but in this jar I don't have the GoogleCloudMessaging package (http://developer.android.com/reference/com/google/android/gms/gcm/GoogleCloudMessaging.html), and yes I see that the GCMRegistar class work but I dont understood why here it is write that this class is deprecated (http://developer.android.com/reference/com/google/android/gcm/GCMRegistrar.html) – user2571821 Jul 11 '13 at 12:14