0

使用这个例子在谷歌地图上绘制一条线/路径我不断地从 LogCat 获得以下错误:它似乎找不到类 com.google.android.maps.Mapview - 我已经导入了 com.google.android.maps .MapView 但不知道如何创建这个明显的类 - 有人可以建议吗?谢谢

05-23 20:35:46.542: E/dalvikvm(408): Could not find class 'com.google.android.maps.MapView', referenced from method com.geomatrix.direction.MapdirectionActivity.onCreate
05-23 20:35:46.542: W/dalvikvm(408): VFY: unable to resolve check-cast 342 (Lcom/google/android/maps/MapView;) in Lcom/geomatrix/direction/MapdirectionActivity;
05-23 20:35:46.542: D/dalvikvm(408): VFY: replacing opcode 0x1f at 0x0016
05-23 20:35:46.550: D/dalvikvm(408): VFY: dead code 0x0018-0182 in Lcom/geomatrix/direction/MapdirectionActivity;.onCreate (Landroid/os/Bundle;)V
05-23 20:35:46.639: D/AndroidRuntime(408): Shutting down VM
05-23 20:35:46.649: W/dalvikvm(408): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-23 20:35:46.679: E/AndroidRuntime(408): FATAL EXCEPTION: main
05-23 20:35:46.679: E/AndroidRuntime(408): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.geomatrix.direction/com.geomatrix.direction.MapdirectionActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class com.geomatrix.direction.MapView
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.os.Looper.loop(Looper.java:123)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-23 20:35:46.679: E/AndroidRuntime(408):  at java.lang.reflect.Method.invokeNative(Native Method)
05-23 20:35:46.679: E/AndroidRuntime(408):  at java.lang.reflect.Method.invoke(Method.java:521)
05-23 20:35:46.679: E/AndroidRuntime(408):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-23 20:35:46.679: E/AndroidRuntime(408):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-23 20:35:46.679: E/AndroidRuntime(408):  at dalvik.system.NativeStart.main(Native Method)
05-23 20:35:46.679: E/AndroidRuntime(408): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class com.geomatrix.direction.MapView
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-23 20:35:46.679: E/AndroidRuntime(408):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.app.Activity.setContentView(Activity.java:1647)
05-23 20:35:46.679: E/AndroidRuntime(408):  at com.geomatrix.direction.MapdirectionActivity.onCreate(MapdirectionActivity.java:30)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-23 20:35:46.679: E/AndroidRuntime(408):  ... 11 more
05-23 20:35:46.679: E/AndroidRuntime(408): Caused by: java.lang.ClassNotFoundException: com.geomatrix.direction.MapView in loader dalvik.system.PathClassLoader[/data/app/com.geomatrix.direction-1.apk]
05-23 20:35:46.679: E/AndroidRuntime(408):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-23 20:35:46.679: E/AndroidRuntime(408):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-23 20:35:46.679: E/AndroidRuntime(408):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.view.LayoutInflater.createView(LayoutInflater.java:466)
05-23 20:35:46.679: E/AndroidRuntime(408):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
05-23 20:35:46.679: E/AndroidRuntime(408):  ... 20 more

有人可以帮忙吗?我会斗鸡眼

4

2 回答 2

1

我遇到了同样的问题,我发现我的 xml 标签中缺少“google”引用。我最初有它,比如“com.android.maps.MapView”,这显然是错误的。它应该类似于以下内容

<com.google.android.maps.MapView
  android:id="@+id/map"
  android:apiKey="mapAPIkey"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:clickable="true"
/>  
于 2012-06-03T16:49:01.837 回答
0

您是否在清单中包含下一行?

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

并将其放在正确的位置(在开始的应用程序标记之后),例如:

<application
    android:hardwareAccelerated="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <uses-library
        android:name="com.google.android.maps"
        android:required="true" />

    <activity ...
于 2012-05-23T21:39:24.410 回答