更新:
在我的 Android SDK 管理器中,我安装了 Android 支持库。在我的 Downloads/android-sdk-macosx/extras/android/support 目录中,我有 v4、v7 和 v13。我将 android-support-v4.jar 复制到 libs 文件夹。右键单击并选择构建路径 > 配置构建路径。在活动布局中,我添加了以下内容(使用 supportmapfragment 而不是 mapfragment):
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
但我仍然收到此错误:
04-16 17:42:00.928: E/AndroidRuntime(363): FATAL EXCEPTION: main
04-16 17:42:00.928: E/AndroidRuntime(363):
java.lang.RuntimeException:
Unable to start activity ComponentInfo{com.otl.AndroidRemoteApp1/
com.otl.AndroidRemoteApp.ShowMapActivity}:
android.view.InflateException: Binary XML file line #6: Error
inflating class fragment
这是完整的跟踪:
04-18 10:33:32.075: E/AndroidRuntime(368): FATAL EXCEPTION: main
04-18 10:33:32.075: E/AndroidRuntime(368): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.otl.AndroidRemoteApp1/com.otl.AndroidRemoteApp.ShowMapActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
04-18 10:33:32.075: E/AndroidRuntime(368): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.os.Handler.dispatchMessage(Handler.java:99)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.os.Looper.loop(Looper.java:130)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-18 10:33:32.075: E/AndroidRuntime(368): at java.lang.reflect.Method.invokeNative(Native Method)
04-18 10:33:32.075: E/AndroidRuntime(368): at java.lang.reflect.Method.invoke(Method.java:507)
04-18 10:33:32.075: E/AndroidRuntime(368): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-18 10:33:32.075: E/AndroidRuntime(368): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-18 10:33:32.075: E/AndroidRuntime(368): at dalvik.system.NativeStart.main(Native Method)
04-18 10:33:32.075: E/AndroidRuntime(368): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
04-18 10:33:32.075: E/AndroidRuntime(368): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-18 10:33:32.075: E/AndroidRuntime(368): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.app.Activity.setContentView(Activity.java:1657)
04-18 10:33:32.075: E/AndroidRuntime(368): at com.otl.AndroidRemoteApp.ShowMapActivity.onCreate(ShowMapActivity.java:45)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-18 10:33:32.075: E/AndroidRuntime(368): ... 11 more
04-18 10:33:32.075: E/AndroidRuntime(368): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.otl.AndroidRemoteApp1-2.apk]
04-18 10:33:32.075: E/AndroidRuntime(368): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-18 10:33:32.075: E/AndroidRuntime(368): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-18 10:33:32.075: E/AndroidRuntime(368): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
04-18 10:33:32.075: E/AndroidRuntime(368): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
04-18 10:33:32.075: E/AndroidRuntime(368): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
04-18 10:33:32.075: E/AndroidRuntime(368): ... 20 more
有任何想法吗?