2013-04-17 86 views
1

更新谷歌地圖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 

任何想法?

+0

你能否粘貼一些相關的Java代碼?這可能會有所幫助。 – dumbfingers

回答

2

僅在API級別12後才支持MapFragment。建議使用SupportMapFragment代替。

要使用此功能,您需要將Android支持庫添加到您的路徑中。按照這些instructions將支持庫添加到您的項目。

UPDATE:

此外,Fragment類不可用,直到API等級11,我相信你的目標薑餅這是API等級10。這就是爲什麼你越來越以下錯誤:

Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader

看到這個Question,它看起來是一個類似的問題。

+0

當我轉到Android SDK Manager時,在Extras下,它顯示已經安裝了「Android支持庫」。鏈接到的文檔說明文件(包括源代碼,示例和.jar文件)被保存到/extras/android/support /目錄中。但是,當我轉到硬盤驅動器(Downloads/android-sdk-macosx/extras/android/support)上的目錄時,我只能看到v4,v7,v13。我的應用程序alreayd在libs目錄中安裝了android-support-v4.jar文件。我想我需要v2.3.jar。我如何得到它? – JohnMerlino

+0

我更新了我的問題 – JohnMerlino

+0

LogCat中還有更多行嗎?它是否給出了「引起人」?你能寄出剩下的日誌嗎? –