0

The guide to setting up GCM here: https://developer.android.com/google/gcm/client.html specifies:

Caution: When you add the Play Services library to your project, be sure to add it with resources, as described in Setup Google Play Services SDK.

Then the page it links to (https://developer.android.com/google/play-services/setup.html#Setup) never mentions the 'with resources' bit.

Does anyone know what this means, as I fear I've missed something when setting up my play services project.

BC2
  • 892
  • 1
  • 7
  • 23
androidneil
  • 880
  • 1
  • 10
  • 21

2 Answers2

1

With recources means as library project, not as JAR file.

  1. Install the Google Play services from SDK manager.

  2. After install it will be at /extras/google/google_play_services/libproject/google-play-services_lib/ So? you can copy this folder in you workspace? if you need.

  3. If you are using Eclipse, import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.

  4. Add Referense to Google Play services in your project. Example http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject

0

Does anyone know what this means

I suspect that it is a clumsy way of emphasizing that you need to attach the Play Services SDK Android library project to your app, rather than just copying over some JAR.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • So after I've created the G-P-S library project in Eclipse, I then reference it in as a library in my own project. Is this enough? I've read a number of messages here that say I also need to have a copy of the jar file within my own app. This seems odd to me. – androidneil Oct 02 '13 at 17:25
  • @androidneil: "Is this enough?" -- it should be. "This seems odd to me" -- that's because it is wrong. However, you may wish to double check the "Order & Export" portions of your build path in both projects: http://stackoverflow.com/questions/16596969/libraries-do-not-get-added-to-apk-anymore-after-upgrade-to-adt-22/16596990#16596990 – CommonsWare Oct 02 '13 at 17:30
  • I'm pretty sure my project is correctly configured. So the problem must be elsewhere. The error occurs when I try to register for GCM, the following line causes a NullPointerException: regid = gcm.register(SENDER_ID); I'd read on another thread that this was caused by problems referencing the google play services lib, hence the original question. – androidneil Oct 02 '13 at 18:15
  • @androidneil: If the error is directly on that line, you never initialized `gcm`. If the error is somewhere inside of the `register()` call, perhaps open a new StackOverflow question where you post your code and the stack trace. – CommonsWare Oct 02 '13 at 18:16
  • Yes I intialized gcm, and logging shows that it's not null. So yes, I'll investigate the trace and see what I find. Thanks. – androidneil Oct 02 '13 at 18:37