为什么我的应用程序崩溃在地图上

时间:2017-01-06 11:05:54

标签: android android-support-library

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dub.app.bridgewaterstate/com.dub.app.bridgewaterstate.ui.CoursesMapScreen}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2442)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2506)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4127)
       at android.app.ActivityThread.-wrap15(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1369)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5491)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
       at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
       at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
       at android.app.Activity.setContentView(Activity.java:2187)
       at com.dub.app.bridgewaterstate.ui.CoursesMapScreen.onCreate(Unknown Source)
       at android.app.Activity.performCreate(Activity.java:6270)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2506)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4127)
       at android.app.ActivityThread.-wrap15(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1369)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5491)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by android.view.InflateException: Binary XML file line #11: Error inflating class fragment
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
       at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
       at android.app.Activity.setContentView(Activity.java:2187)
       at com.dub.app.bridgewaterstate.ui.CoursesMapScreen.onCreate(Unknown Source)
       at android.app.Activity.performCreate(Activity.java:6270)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2506)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4127)
       at android.app.ActivityThread.-wrap15(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1369)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5491)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v4.app.FragmentManagerState
       at android.os.Parcel.readParcelableCreator(Parcel.java:2432)
       at android.os.Parcel.readParcelable(Parcel.java:2358)
       at android.os.Parcel.readValue(Parcel.java:2264)
       at android.os.Parcel.readArrayMapInternal(Parcel.java:2614)
       at android.os.BaseBundle.unparcel(BaseBundle.java:221)
       at android.os.Bundle.getBundle(Bundle.java:763)
       at aby.a(:com.google.android.gms.DynamiteModulesB:74)
       at maps.ad.t.a(Unknown Source)
       at maps.ad.M.a(Unknown Source)
       at xu.onTransact(:com.google.android.gms.DynamiteModulesB:107)
       at android.os.Binder.transact(Binder.java:387)
       at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.getMap(Unknown Source)
       at com.google.android.gms.maps.SupportMapFragment$zza.onInflate(Unknown Source)
       at com.google.android.gms.dynamic.zza$4.getState(Unknown Source)
       at com.google.android.gms.dynamic.zza.zztU(Unknown Source)
       at com.google.android.gms.dynamic.zza.zztU(Unknown Source)
       at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
       at android.support.v4.app.Fragment.performCreateView(Unknown Source)
       at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
       at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
       at android.support.v4.app.FragmentManagerImpl.onCreateView(Unknown Source)
       at android.support.v4.app.FragmentController.onCreateView(Unknown Source)
       at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(Unknown Source)
       at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(Unknown Source)
       at android.support.v4.app.FragmentActivity.onCreateView(Unknown Source)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:754)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
       at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
       at android.app.Activity.setContentView(Activity.java:2187)
       at com.dub.app.bridgewaterstate.ui.CoursesMapScreen.onCreate(Unknown Source)
       at android.app.Activity.performCreate(Activity.java:6270)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2506)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4127)
       at android.app.ActivityThread.-wrap15(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1369)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5491)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

我的布局文件是:

  <RelativeLayout 
       android:layout_width="match_parent"
       android:layout_height="match_parent">
       <include android:id="@+id/courses_map_header_id"
        layout="@layout/widget_ic_action_header" /> 
       <fragment class="com.google.android.gms.maps.SupportMapFragment"  android:id="@+id/courses_map_id" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"
        android:layout_below="@+id/courses_map_header_id"
        android:clickable="true"/> 
    </RelativeLayout>

2 个答案:

答案 0 :(得分:1)

请检查清单文件中是否存在以下内容:

   <meta-data
      android:name="com.google.android.maps.v2.API_KEY"
      android:value="your value" />
   <meta-data
      android:name="com.google.android.gms.version"
      android:value="@integer/google_play_services_version" />

并设置xml布局以显示地图,如下所示:

 <fragment
    android:name="com.google.android.gms.maps.MapFragment"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

答案 1 :(得分:0)

Binary XML file line #11: Binary XML file line #11: Error inflating class

检查xml文件中的这一行,你可能有一个错字。