Google Maps Android API v2 - Sample Code crashes

前端 未结 8 1121
死守一世寂寞
死守一世寂寞 2020-11-30 22:43

I\'m trying to get the sample code of Android \'Google Maps Android API v2\' working. I get the project built without errors. However, when I try to run the app on my Galaxy

8条回答
  •  旧巷少年郎
    2020-11-30 23:45

    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.

提交回复
热议问题