更新谷歌地圖API的Android V2:機器人 - 支持舊設備(薑餅)
在我的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
任何想法?
你能否粘貼一些相關的Java代碼?這可能會有所幫助。 – dumbfingers