Google Maps Android API v2 - Sample Code crashes

前端 未结 8 980
死守一世寂寞
死守一世寂寞 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.

    0 讨论(0)
  • 2020-11-30 23:45

    I faced the same problem and couldn't resolve. Finally I took the sample projects folder from another machine, copied it to mine and loaded the new project I took from the other machine. Then everything is working fine. I tried to track the issue by comparing 2 sample projects but couldn't. Anyway the new sample projects I took from the other machine is working fine.

    0 讨论(0)
提交回复
热议问题