Google Maps Android API v2 – Sample Code crashes

Follow the crib sheet very, very carefully:
https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw

In particular, I think you need to:

  • Import the actual source for the “google-play-services_lib” project and link it as an Android library.
    • Do this through Project -> Properties -> Android -> Library, Add -> google-play-services_lib (you can right click on your project and choose Properties, then select Android).
    • Do not add it as a dependent Project through the “Java Build Path” for your project, that didn’t work for me.
  • Add the google-play-services.jar and android-support-v4.jar into a “libs” folder in the sample project, and add them as “External External JARs” in “Build Path -> Configure Build Path -> Libraries”.

I found this second step was necessary as I was hitting the exact same error as you when trying to use the sample code. The first step was necessary to avoid a NoClassDefFoundError in com.google.android.gms.R$styleable in my real project.

I also needed to do a Clean build and Uninstall the app from the device (from an earlier test attempt) before the sample code worked.

Leave a Comment