谷歌地图Android的API V2 - 样品code崩溃 [英] Google Maps Android API v2 - Sample Code crashes

查看:152
本文介绍了谷歌地图Android的API V2 - 样品code崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得的样品code Android的谷歌地图Android的API V2'的工作。我得到建没有错误的项目。然而,当我尝试在我的Galaxy Nexus的(带USB连接到我的笔记本电脑)运行的应用程序,该应用程序立即崩溃。

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 Nexus (connected with usb to my laptop), the app crashes immediately.

  • 在我填写在AndroidManifest.xml中
  • 我自己的地图API密钥
  • 在我建立针对安卓4.1.2
  • I filled in my own Maps API Key at the AndroidManifest.xml
  • I built against Android 4.1.2

这是记录:

Unable to resolve superclass of Lcom/example/mapdemo/BasicMapActivity; (66) 
Link of class 'Lcom/example/mapdemo/BasicMapActivity;' failed 
Could not find class 'com.example.mapdemo.BasicMapActivity', referenced from method com.example.mapdemo.MainActivity.<clinit> 
VFY: unable to resolve const-class 108 (Lcom/example/mapdemo/BasicMapActivity;) in Lcom/example/mapdemo/MainActivity; 
VFY: replacing opcode 0x1c at 0x000d 
Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/example/mapdemo/MainActivity; 
Class init failed in newInstance call (Lcom/example/mapdemo/MainActivity;) 
Shutting down VM 
threadid=1: thread exiting with uncaught exception (group=0x41ac9930) 
FATAL EXCEPTION: main 
java.lang.ExceptionInInitializerError
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.NoClassDefFoundError: com.example.mapdemo.BasicMapActivity
at com.example.mapdemo.MainActivity.<clinit>(MainActivity.java:97)
... 15 more

没有任何人有一个提示如何解决这个或我可能是做错了?

Does anybody have a hint how to solve this or what I might be doing wrong?

推荐答案

按照垛板非常,非常小心:
<一href="https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw">https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw

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:

  • 导入为谷歌播放services_lib项目实际出处及链接它作为一个机器人库。
    • 请通过此项目 - >属性 - > Android的 - >库,添加 - >谷歌播放services_lib(你可以右键点击你的项目,并选择属性,然后选择Android的)。
    • 不可以添加为通过Java构建路径为您的项目相关的项目,这并没有为我工作。
    • 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.

      我发现这第二个步骤是必要的,因为我试图使用示例code击球时完全相同的错误,因为你。第一步是要避免的NoClassDefFoundError com.google.android.gms.R $设置样式在我的现实项目。

      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.

      我还需要前样品code的工作做一个干净的构建,并从设备上删除应用程序(从早期的测试中尝试)。

      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.

      这篇关于谷歌地图Android的API V2 - 样品code崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆