Android,启动地图视图时出错

时间:2011-09-06 16:28:27

标签: android maps android-mapview

我有一个mapview类,它扩展了MapActivity。我正在使用的代码遵循Hello Map View教程。使用以下代码按下按钮启动地图活动:

public void showMap() {

         Intent myIntent = new Intent(MainActivity.this, googleMapsView.class);
         MainActivity.this.startActivity(myIntent);


     }

我遇到的问题是当我启动地图视图时应用程序崩溃,我在log cat中收到以下错误:

09-06 15:50:03.507: ERROR/AndroidRuntime(877): FATAL EXCEPTION: main
09-06 15:50:03.507: ERROR/AndroidRuntime(877): java.lang.NoClassDefFoundError: com.android.googleMapsView
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at com.android.MainActivity.showMap(MainActivity.java:832)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at com.android.MainActivity$3$2.onClick(MainActivity.java:262)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at android.view.View.performClick(View.java:3110)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at android.view.View$PerformClick.run(View.java:11934)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at android.os.Handler.handleCallback(Handler.java:587)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at android.os.Looper.loop(Looper.java:132)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at android.app.ActivityThread.main(ActivityThread.java:4123)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at java.lang.reflect.Method.invokeNative(Native Method)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at java.lang.reflect.Method.invoke(Method.java:491)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at dalvik.system.NativeStart.main(Native Method)
09-06 15:50:03.507: ERROR/AndroidRuntime(877): Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at dalvik.system.DexFile.defineClass(Native Method)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:207)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:211)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at java.lang.ClassLoader.loadClass(ClassLoader.java:540)
09-06 15:50:03.507: ERROR/AndroidRuntime(877):     at java.lang.ClassLoader.loadClass(ClassLoader.java:500)

1 个答案:

答案 0 :(得分:0)

确保您已将Google API指定为项目构建目标。还要确保清单文件中包含以下行:

<uses-library android:name="com.google.android.maps" />