我'm working with the HelloGoogleMaps tutorial on the Android Developers'资源页面(http://developer.android.com/resources/tutorials/views/hello-mapview.html),当我在我的模拟器上运行应用程序的第1部分("Creating a Map Activity")时,我收到消息"The application HelloGoogleMaps (process com.example) has stopped unexpectedly. Please try again."我'm pretty sure that I followed all of the instructions correctly, however I'我不确定我是否正确设置了我的模拟器环境 . 任何人都可以帮我弄清楚发生了什么事吗?谢谢 .
这是logcat的输出:
I/ActivityManager( 63): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example/.HelloGoogleMaps }
I/ActivityManager( 63): Start proc com.example for activity com.example/.HelloGoogleMaps: pid=344 uid=10026 gids={3003, 1015}
D/ddm-heap( 344): Got feature list request
W/dalvikvm( 344): Class resolved by unexpected DEX: Lcom/example/HelloGoogleMaps;(0x43d02e18):0x11fbb0 ref [Lcom/google/android/maps/MapActivity;] Lcom/google/android/maps/MapActivity;(0x43d02e18):0x11f510
W/dalvikvm( 344): (Lcom/example/HelloGoogleMaps; had used a different Lcom/google/android/maps/MapActivity; during pre-verification)
W/dalvikvm( 344): Unable to resolve superclass of Lcom/example/HelloGoogleMaps; (41)
W/dalvikvm( 344): Link of class 'Lcom/example/HelloGoogleMaps;' failed
D/AndroidRuntime( 344): Shutting down VM
W/dalvikvm( 344): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime( 344): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 344): java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
E/AndroidRuntime( 344): at dalvik.system.DexFile.defineClass(Native Method)
E/AndroidRuntime( 344): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:209)
E/AndroidRuntime( 344): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:203)
E/AndroidRuntime( 344): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime( 344): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime( 344): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 344): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
E/AndroidRuntime( 344): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime( 344): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime( 344): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime( 344): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 344): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 344): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 344): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 344): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 344): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 344): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 344): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 63): Sending signal. PID: 344 SIG: 3
I/dalvikvm( 344): threadid=7: reacting to signal 3
E/dalvikvm( 344): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
W/ActivityManager( 63): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 63): Activity idle timeout for HistoryRecord{43dc9818 com.example/.HelloGoogleMaps}
D/dalvikvm( 143): GC freed 2317 objects / 132032 bytes in 107ms
4 回答
嗨,我不确定您是否遇到了与我相同的问题,但请确保您的清单中的 Map 和互联网许可是在活动括号内,而不是清单,即:
机器人:主题= “@安卓风格/ Theme.NoTitleBar”>
以下内容有效(它显示的是 Map 而不仅仅是网格):
AndroidManifest.xml中
将这些使用许可放在哪里很重要 . 此外,我怀疑它在添加ACCESS_COARSE_LOCATION后开始工作 .
main.xml中
密钥是通过以下两步程序获得的:
步骤1:
step2:99:99 ...在http://code.google.com/android/maps-api-signup.html给了google,获得了密钥 .
没有此键,MapView只显示一个网格,但不起作用 .
但是......我必须尝试使用释放密钥,然后再使用调试密钥再次运行 . 不知道我改变了什么 . 也许诀窍是用不同的证书安装它 .
我必须补充一点
并不意味着有一个错误 . Map 可以工作,并仍然在日志中打印 .
工作应用程序的日志如下所示:
“uses-library”应该在应用程序标记内 . “uses-permission”应该在应用程序标记之外 .
你做到了吗?