Google Clould Message demo setup : Dependencies not found - android

I want to integrate GCM into my android app. For the beginning I wanted to test the GCM demo that comes with the Google tutorial on how to use GCM http://developer.android.com/google/gcm/client.html
I downloaded the demo project an imported it into my ADT eclipse. So this is what I did:
I downloaded the "Google Play services" via SDK Manager and additionally "Google Repository"
I copied the "/extras/google/google_play_services/libproject/google-play-services_lib/" into my workspace (as recommended by the tutorial)
On the following screenshot you can see that I added the copy of "google-play-services_lib" as a Library to the GCM demo project
However, the dependencies are not resolved as the following screenshot shows:
So at what point in the instructions chain did I make an error?

Google Play Services doesn't contain GCMRegistrar class. That class is part of the deprecated GCM Client library. Instead of using GCMRegistrar, use com.google.android.gms.gcm.GoogleCloudMessaging class to register to GCM.
You are using an old version of the GCM Demo. Try the current version here.

Please follow GCM sample code from here

Related

import com.google.android.gcm cannot be resolved in Eclipse

I wanted to use GCM Push Notifications in my Android App which I am developing in Eclipse.
I have updated my SDK Tools as you can see in the uploaded picture.
I still cant find any jars in extras/google/
How can I download the required jars and add them to my project?
My Android SDK Manager:
if you want to use the gcm library try import the existing project from the directory directly from
Android_SDK_Location\extras\google\google_play_services\libproject\google-play-services_lib
Use it as a library project.
Just remind you that now google provided the Firebase for the push notification which needs to use firebase sdk.
FYR: https://developers.google.com/cloud-messaging/
and i think the question may be duplicated?

Cannot resolve symbol gcm (Android Studio 0.8.9)

Im trying to use Google Cloud Messaging with Android Studio, but it cannot find android:name="com.google.android.gcm.GCMBaseIntentService" and the gcm and GcmIntent appears in read. I have intalled Google play services v 6.1.11.
In the build.gradle i have compile "com.google.android.gms:play-services:6.1.11" as dependency.
How, i have that installed.
I had open the google play services directoy and i havent found gcm. I have gcm installed from sdk manager but still doesnt recognize .GCMBaseIntentService and .GcmIntentService
com.google.android.gcm.GCMBaseIntentService is an old deprecated class that belonged to the deprecated gcm.jar. Since you are using Google Play Services library, there's no need for you to use GCMBaseIntentService.
Make sure you update or install 'Google Repository' on the SDK manager. Also make sure that you are pointing to the right SDK path.
Go to:
File>Project Structure> SDK Location
GCMBaseIntentService is depicted and part of play service lib (3.1+) so you don't have to add any other jar file. gcm.jar is obsolete now, you can find it in SDK also.
According to android documentation add below line in gradle.build file (latest version)
dependencies {
compile "com.google.android.gms:play-services:6.5.87"
}
For more info
http://developer.android.com/reference/com/google/android/gms/gcm/GoogleCloudMessaging.html

Google Analytics v4 in Android: Could not find class 'com.google.android.gms.analytics.Tracker'

I am desperately trying to integrate GA v4 in my Android app.
And I followed the guide here https://developers.google.com/analytics/devguides/collection/android/v4/
And integrated Google Play Services lib as described, but it gives me
Could not find class 'com.google.android.gms.analytics.Tracker
But I can find classes and its namespaces in the project.
I can't figure out what's happening here.
I followed also the instruction on Analytics for Android v4.
But additionally I had to update play services and build tools in the SDK manager. Then I had to add compile 'com.google.android.gms:play-services:8.4.0' in the app build.gradle (above of compile 'com.google.android.gms:play-services-analytics:8.4.0'. The Tracker class was still unknown (red underlined) but despite of that I pressed "Run" (install app) in Android Studio and only then analytics was recognized and could be used.
I had the same problem and the reason was my Google Play services package was outdated.
Using Eclipse, I went into Window > Android SDK Manager, checked only Google Play services package (under "Extras" in the bottom), updated it and created a new lib project.
Then I followed the steps in tutorial below to create a new google play services lib project.
https://developer.android.com/google/play-services/setup.html
Hope it helps!
/Paulo

Google Cloud Messaging for Android Library not Found in the sdk Manager

I am trying to implement a push notification solution for android.I am following the steps given in the following tutorial http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
but when i tried to install the Google Cloud Messaging for Android Library using the android sdk(i am using the latest sdk) i don't find it the extras module like you can see in this picture
This is really strange.
Is there any solution?
Select the 'Show Obsolete Packages' option in Packages menu and you will be able to view it and install.
Install Google Play Services Library
For client side implementation of GCM use this link
For server side purposes follow the tutorial
Pls note that the tutorial explains how you can send messages to individual devices using the registration id and not to all devices at one go.
[Update]
I observed that still some people are using the deprecated library - GCM for android.
"Google Cloud Messaging for Android" is deprecated and no more used.GCM API's are now available as part of "Google Play Services".
Eventhough #anubhav's answer is correct for the asked question it is not recommended.
Seems like this package is now obsolete. In order to see it in SDK Manager I had to check "Show obsolete packages" in the "Packages" menu
Edit (clarification of my answer)
I encountered this problem when trying to run Maven Android SDK Deployer. The version of the SDK deployer I used, was expecting gcm package installed (at least when running the deployer in its default configuration).
For other purposes, it's recommended to use the newer Google Play Services instead, as stated in one of the answers here.
To Add Google Play Services to Your Project (For Android Studio)
Open the build.gradle (Module:app) file inside your application module directory.
Add a new build rule under dependencies for the latest version of play-services.
For example:
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
3.Save the changes and click Sync Project with Gradle Files in the toolbar.
4.Open your app's manifest file and add the following tag as a child of the <application> element:
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
go here for more details :Setting up google play services
Is there any solution?
Use something newer than that tutorial. The old GCM API was deprecated last May and was replaced with a new one.
Just tick the "Obsolete" checkbox in Android SDK Manager popup.
the Google Cloud Messaging for Android Library is obsolete,you can find it by do this: sdk manager --> packages(left corner)-->show obsolete packages,then you will see it.but google sugessts to use Googleplay Service instead.

GCM Demo Application's failure to register to tomcat server

i have tried and finished 90% of GCM Demo application for android from the link: http://developer.android.com/guide/google/gcm/demo.html So i would like to ask your favour for the following error. I googled and referred many websites and forums for the solution. But i could not figure it out. So please help me. Thank you.
You need to install the helper libraries and make required changes to the emulator.
Goto your android SDK folder and open SDK Manager and install Google Cloud Messaging for Android Library under Extras section. (If you don’t see Google Cloud Messaging for Android Library update your SDK manager to latest version)
After installing the library it will create gcm.jar file in your Andoird_SDK_Folder\extras\google\gcm\gcm-client\dist. Later you need to add this .jar file to your android project.
Now open your AVD Manager and create a new Google API emulator and start the emulator. (Note: To test gcm application in emulator you need to test it on Google API device only)
After launching emulator press Menu button goto Settings. Select Accounts & Sync. And then press Add Account button and add a Google account.
Finally Test your Application on Simulator.

Categories

Resources