我正在製作一個簡單的應用程序,用於播放音樂並顯示Google地圖。當我嘗試在主要活動中放置地圖時,我會收到「錯誤膨脹類別片段」。Android-錯誤充氣課程片段
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(MainActivity.LOG_TAG, "activity started");
gmap = ((MapFragment)getFragmentManager().findFragmentById(R.id.fragment1)).getMap();
music = new MusicServiceWrapper(this);
}
,這裏是佈局文件
<fragment
android:id="@+id/fragment1"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/linearLayout1"
android:layout_alignLeft="@+id/linearLayout2" />
爲什麼我得到這個錯誤任何想法的一部分嗎?
編輯:我會包括一些錯誤的logcat的(線132指XML片段給我的第一行)
04-01 01:43:35.972: E/Trace(625): error opening trace file: No such file or directory (2)
04-01 01:43:36.572: D/AndroidRuntime(625): Shutting down VM
04-01 01:43:36.572: W/dalvikvm(625): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
04-01 01:43:36.582: E/AndroidRuntime(625): FATAL EXCEPTION: main
04-01 01:43:36.582: E/AndroidRuntime(625): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.kenpowers.gea/net.kenpowers.gea.MainActivity}: android.view.InflateException: Binary XML file line #132: Error inflating class fragment
04-01 01:43:36.582: E/AndroidRuntime(625): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
04-01 01:43:36.582: E/AndroidRuntime(625): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-01 01:43:36.582: E/AndroidRuntime(625): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-01 01:43:36.582: E/AndroidRuntime(625): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-01 01:43:36.582: E/AndroidRuntime(625): at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 01:43:36.582: E/AndroidRuntime(625): at android.os.Looper.loop(Looper.java:137)
04-01 01:43:36.582: E/AndroidRuntime(625): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-01 01:43:36.582: E/AndroidRuntime(625): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 01:43:36.582: E/AndroidRuntime(625): at java.lang.reflect.Method.invoke(Method.java:511)
04-01 01:43:36.582: E/AndroidRuntime(625): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-01 01:43:36.582: E/AndroidRuntime(625): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-01 01:43:36.582: E/AndroidRuntime(625): at dalvik.system.NativeStart.main(Native Method)
04-01 01:43:36.582: E/AndroidRuntime(625): Caused by: android.view.InflateException: Binary XML file line #132: Error inflating class fragment
04-01 01:43:36.582: E/AndroidRuntime(625): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-01 01:43:36.582: E/AndroidRuntime(625): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
你能不能從logcat的分享確切異常堆棧? – sandrstar
我添加了LogCat的前20行。希望有所幫助。 – nh0815
您是否找到解決方案? – ashack