Android - 绘制路径

时间:2012-05-23 20:54:52

标签: android google-maps

使用此示例Drawing a line/path on Google Maps我一直关闭来自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

有人可以帮忙吗?我正在睁眼睛

2 个答案:

答案 0 :(得分: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"
/>  

答案 1 :(得分: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 ...