2013-06-28 125 views
0

我正在使用我的老闆的手機來測試我們在iOS上開發的應用程序,然後轉移到android。谷歌地圖V2'應用程序意外停止'android SDK v9

我跟着this教程,當在手機上運行給出了標題中提到的錯誤。我已經讀過10個以下的SDK不支持地圖是不是?相當不確定從這裏做什麼。代碼:

我有3個標籤,我加載的片段,並在討論的片段是:

注:所有的進口都正確

public class EventFragment extends Fragment { 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
     Bundle savedInstanceState) { 

     // Inflate the layout for this fragment 
     View V = inflater.inflate(R.layout.event_layout, container, false); 

     return V; 
    } 
} 

在視圖中的XML文件:

<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/the_map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:name="com.google.android.gms.maps.MapFragment" 
    map:cameraTilt="45" 
    map:cameraZoom="14" 
    /> 

一切都在應該是清單。當我刪除它運行良好。有這種事情的修復嗎?

編輯:

logcat的錯誤:

06-28 11:25:51.230: E/AndroidRuntime(3405): FATAL EXCEPTION: main 
06-28 11:25:51.230: E/AndroidRuntime(3405): android.view.InflateException: Binary XML file line #1: Error inflating class fragment 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.view.LayoutInflater.inflate(LayoutInflater.java:386) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at co.uk.dwdks.kendalmintfest.KendalInfoFragment.onCreateView(KendalInfoFragment.java:16) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.os.Handler.handleCallback(Handler.java:587) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.os.Handler.dispatchMessage(Handler.java:92) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.os.Looper.loop(Looper.java:143) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.app.ActivityThread.main(ActivityThread.java:4196) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at java.lang.reflect.Method.invokeNative(Native Method) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at java.lang.reflect.Method.invoke(Method.java:507) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at dalvik.system.NativeStart.main(Native Method) 
06-28 11:25:51.230: E/AndroidRuntime(3405): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.Fragment.instantiate(Fragment.java:401) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.Fragment.instantiate(Fragment.java:369) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  ... 18 more 
06-28 11:25:51.230: E/AndroidRuntime(3405): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment in loader dalvik.system.PathClassLoader[/data/app/co.uk.dwdks.kendalmintfest-2.apk] 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  at android.support.v4.app.Fragment.instantiate(Fragment.java:391) 
06-28 11:25:51.230: E/AndroidRuntime(3405):  ... 21 more 
+0

此錯誤消息說沒有。請添加從你的logcat的堆棧跟蹤... – WarrenFaith

+0

嗨@WarrenFaith我更新了我的問題與logcat,這是唯一顯示從這個建設和它的綠色 –

+0

這不能是你的logcat ... – WarrenFaith

回答

2

我認爲你需要實現SupportFragment和碎片類需要是:類=「com.google.android.gms.maps.SupportMapFragment」

+0

嗨,感謝您的評論!這已經消除了錯誤,它說:「這個應用程序不會運行沒有谷歌播放服務」現在,我可以安全地下載這個? –

+0

如果您收到一個新的異常,例如:R $ stylable中的NoClassDefFound比您需要添加地圖programmaticaly :-) – Informatic0re

+0

您是否執行了此操作:https://developers.google.com/maps/documentation/android/start – Informatic0re

0

地圖工作(AFAIR)開始形式API8。但是,您需要將您的應用與google-play-servces_lib關聯起來,這很可能在您的情況下不會完成。同時確保你獲得了在Manifest中設置的所有權限。最後,檢查的官方文檔:https://developers.google.com/maps/documentation/android/