I'm trying to implement Push Notification. I have a problem with import com.google.android.gcm.GCMRegistrar it cannot be resolved.
I did install Google Play Services and add google-play-services_lib to my projects folder.
But the problem remains. I tried to find gcm.jar as I saw solutions that worked for others, but I don't have this .jar.
Is there something else that I'm missing?
First of all download Google Cloud Messaging for Android Library. For this goto Android SDK Manager->Extras->Google Cloud Messaging for Android Library check and install it.
See the below image:
Now, after downloading this libary you'll see gcm folder is available into path D:\.....\android-sdk\extras\google
Now You'll find gcm.jar into path D:\....\android-sdk\extras\google\gcm\samples\gcm-demo-client\libs.
Now, add this gcm.jar file into your project
GCMRegistrar GCM API is deprecated.It is recommended to refer updated documentation on Google developer Site
Our Google overlords have decried that gcm.jar is deprecated as of Summer 2013 so whatever example code you're working off that requires GCMRegistrar.java is a bit outdated. Of course, just adding gcm.jar works well as stated in the other answers.
If you want to follow Google's commands for whatever reason, CommonsWare has an updated GCM example project that basically just copies the needed classes from gcm.jar and renames them with a 'compat' suffix:
https://github.com/commonsguy/cw-omnibus/tree/master/Push/GCMClient2/src/com/commonsware/android/gcm/client
Related
I have a working Android app using:
Google Maps (play-services-maps)
Google Location, Activity Recognition, and Places (play-services-location)
Google Analytics (play-services-analytics)
Google Mobile Ads (play-services-ads)
I'm currently using version 8.3.0, everything works fine. I'd like to upgrade to the last version, 9.2.0. When I change the number in the gradle files, Android Studio is unable to find the APIs packages & classes (saying "package XXX does not exist" and "Cannot find symbol class YYY").
I currently have no google-services.json file, do I need it now? I tried without success, probably because I have several modules / submodules, and I don't know where the json file is needed or not.
The problem is that I need a package name to create the JSON file, and I have some library modules, without package name, using Google APIs.
If needed, here is the project structure:
Maybe you did something wrong while upgrading your project. Make sure you follow the correct steps in upgrading. I suggest you to retry the process of upgrading, but make sure you do the correct way. Like in configuring your build and setting up Google play service.
For your question about google-services.json, Google-services.json contains developer credentials and configuration settings, which is needed to verify while connecting with GoogleApiClient. Though your service is working fine without it. But it will only work with your test device, as it is detecting your developer account. And after you releae your app in public, it will not work without the json file. So you need it and don't delete.
sources: What does google-services.json really do?
So, I finally got it: I was using the AutocompletePrediction.getDescription() method, which has simply been removed (and replaced by AutocompletePrediction.getDescription .getFullText()). That call made gradle stops building -_- .
Thanks Google for removing stuff without deprecating it for a while (though the docs says that the method is deprecated: https://developers.google.com/places/android-api/releases)...
I can also confirm that in my case, the google-service.json file is NOT required.
I am trying to have leaderboards in my android app. I was trying to use the library BaseGameUtils. This library is referencing the google play services library. When I clean my workspace I get the message for the library BaseGameUtils that the google-play-services_lib.jar is missing in a specified path. But actually the jar file is there in that path. Because of this When I refer the library BaseGameUtils the actual game APP is having an error marking. Kindly assist me to resolve this
More info might help to clarify your question more.
But let me see if my being from struggling with the Play Games Service for the past day helps:
first of all, make sure your Google Play Service is updated through SDK manager. After that, COPY THE ENTIRE FOLDER google-play-services_lib to your project and do all the referencing work accordingly.
After all that, check to see if the file res/values/version.xml from google-play-service_lib has the updated version number 4323000
I am using GCM in my project for push notifiaction, but when I added google play service library into my project after importing this, A red exclamation mark appeared in my project, I already have seen different question and answers regarding this problem when I saw my build path of project there is cross sign on Android dependencies folder please help me,
You are supposed to import the whole google play project and use it as a library project for your own project, not just the jar. Try Google's guide again.
Check to see if your google play lib looks like this:
That means the jar is not available in bin directory...check manually that the jar is available or not in that directory..
I have been working with Java for about a couple of months now and I have been stuck introducing Google API into my Maps app. I need some help with these imports.
Here is what I did: I was following the code of a Places API demo which I can link if needed. I ended up having to add some libraries. Before I did, I was getting errors from all of the imports that started with com.google.api.client...etc. Then once I added all of these libraries, I then got left with 2 errors out of my imports.
The errors are: the "com.google.api.client.googleapis.GoogleHeaders" and "com.google.api.client.http.json.JsonHttpParser". I am receiving them both as "cannot be resolved to a type". These errors are causing some more errors throughout the rest of my code. I was hoping someone can help me solve this. I know it should have something to do with my code, but I am not sure what is going on. I know I am missing something.
Also, I installed the Google Plugin to install the APIs and when I did, I added the "Google + API" and the "GoogleOAuth2" APIs and that is where I am stuck at. Please someone help.
Here is the screenshot: Full Screenshot
I haven't worked with Maps, but as I understand it Maps is now packaged with Google Play Services, which I have been working with recently.
Firstly, the installation of Google Play Services is well-documented and you should look at this (if you haven't done so already):
http://developer.android.com/google/play-services/setup.html
There are a few areas that cause difficulty, and one is the section "Set Up a Project with the Library". There are different possible approaches but I suggest you take the following steps.
Ensure that the Google Play Services lib (and any other libs) are defined as library projects (Properties ...Android.. Library ...IsLibrary) and that they have no errors (cleaning may not be sufficient - you may have to shut down Eclipse to remove the errors).
When the library projects are error free, add them to your project. The normal way of doing this is to REFERENCE them (check what the documentation says) but you do this by (Properties ...Android.. Library ...Add).
Then check out (Properties ... Java Build Path ...) - read the documentation but you need your libs in here.
Then clean your project but note that a restart of Eclipse may be necessary to remove the errors from your project.
There are other errors that can arise - another common one arises if you have different versions of the v4 support lib in your libs / project and you get a message "...this check is based on SHA1 at this time". This is well documented on Stack Overflow.
Good luck !
I have a problem as:
I didn't find where can I get this Jar file gcm.jar? also where Can I put it ?.
Note I used Android 4.1.
Start SDK Manager and scroll down to the section "Extras" and make sure you have installed Google Cloud Messaging for Android Library, if not, install the package.
The package will be installed in the directory "your-android-sdk\extras\google\gcm\"
Client code (for example to be used in Android app):
gcm\gcm-client\
Server code (where the Client connects to and registers it's regId):
gcm\gcm-server\
To add the gcm client-jar (gcm.jar) to your Android-project, copy it to the "libs"-folder in your Eclipse project and right click on the file and select Build Path --> Add to Build Path.
The GCM Helper libraries (gcm.jar) has been deprecated.
The documentation for the library (https://developer.android.com/google/gcm/helper.html)
now displays a messaging stating:
The information in this document has been superseded by GCM Server and GCM Client. Please use the GoogleCloudMessaging API instead of the GCM client helper library. The GCM server helper library is still valid.
Implementing a GCM server is documented here: https://developer.android.com/google/gcm/server.html
Implementing a GCM client is now documented here: developer.android.com/google/gcm/client.html (sorry, can't post as a link because I don't have enough rep).
As on today's date, SDK Manager now has the option to "Show obsolete packages" (Packages->Show obsolete packages). This allows you to install GCM through the SDK Manager itself.
Go to this link
https://dl-ssl.google.com/android/repository/gcm_r03.zip
when download completes extract the zip file, you will get three directories with names client side, server side and samples.
now open your SDK folder and create a folder named "extras/android" and paste all three folders here DONE!!
now whenever make a new project in project classpath using add external jar add gcm.jar.
refer
Just for the Recored: I followed the steps provided by chrkad but I found the .jar file in the DIST folder and NOT in the JAR folder. After I found that out I saw that Peter Gluck postet that before.
I hope that this could save some time to ppl having this issue! (took me 20 minutes)
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
See details from answer
https://stackoverflow.com/a/23092848/4255980