Binary XML file line #8: Error inflating class fragment in Fragment Activity

I am using Activity which extends FragmentActivity , but at some point of time it gives an error . Below are my whole logs that comes after exception . And the line which errors are pinting are setContentView(R.layout.activity_user_location);

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.parse.makemymosaic/com.parse.makemymosaic.UserLocation}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class fragment
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
                                                                        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4098)
                                                                        at android.app.ActivityThread.-wrap15(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1360)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:148)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5443)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        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 #8: Binary XML file line #8: 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:2176)
                                                                        at com.parse.makemymosaic.UserLocation.onCreate(UserLocation.java:119)
                                                                        at android.app.Activity.performCreate(Activity.java:6259)
                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
                                                                        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4098) 
                                                                        at android.app.ActivityThread.-wrap15(ActivityThread.java) 
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1360) 
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                        at android.os.Looper.loop(Looper.java:148) 
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5443) 
                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                        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 #8: 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:2176) 
                                                                        at com.parse.makemymosaic.UserLocation.onCreate(UserLocation.java:119) 
                                                                        at android.app.Activity.performCreate(Activity.java:6259) 
                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) 
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
                                                                        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4098) 
                                                                        at android.app.ActivityThread.-wrap15(ActivityThread.java) 
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1360) 
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                        at android.os.Looper.loop(Looper.java:148) 
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5443) 
                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
                                                                     Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f080013 type #0x6 is not valid
                                                                        at android.content.res.Resources.getDimensionPixelSize(Resources.java:697)
                                                                        at com.google.maps.api.android.lib6.impl.ar.h(:com.google.android.gms.DynamiteModulesB@11951438:70)
                                                                        at com.google.maps.api.android.lib6.impl.fk.<init>(:com.google.android.gms.DynamiteModulesB@11951438:20)
                                                                        at com.google.maps.api.android.lib6.impl.ba.a(:com.google.android.gms.DynamiteModulesB@11951438:49)
                                                                        at com.google.maps.api.android.lib6.impl.ba.a(:com.google.android.gms.DynamiteModulesB@11951438:1)
                                                                        at com.google.maps.api.android.lib6.impl.cm.a(:com.google.android.gms.DynamiteModulesB@11951438:24)
                                                                        at com.google.android.gms.maps.internal.s.onTransact(:com.google.android.gms.DynamiteModulesB@11951438:45)
                                                                        at android.os.Binder.transact(Binder.java:387)
                                                                        at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onCreateView(Unknown Source)
                                                                        at com.google.android.gms.maps.SupportMapFragment$zza.onCreateView(Unknown Source)
                                                                        at com.google.android.gms.dynamic.zza$4.zzb(Unknown Source)
                                                                        at com.google.android.gms.dynamic.zza.zza(Unknown Source)
                                                                        at com.google.android.gms.dynamic.zza.onCreateView(Unknown Source)
                                                                        at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
                                                                        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
                                                                        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1255)
                                                                        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1472)
                                                                        at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3467)
                                                                        at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120)
                                                                        at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView

And app is stopped .Below is my xml for line 8

 <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/nestedView"
        tools:context="com.parse.*****.UserLocation" />   

And below is my Activity

public class UserLocation extends FragmentActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener,
    LocationListener,
    GoogleMap.OnMarkerClickListener,
    GoogleMap.OnMarkerDragListener {

And fragment is match parent but there are some views below it, that is relative layout for showing information

2 answers

  • answered 2018-01-14 09:19 Pankaj Kant Patel

    this will fix your problem.just do it

    layout file

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" /> 
    

    class file

    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    
    import com.google.android.gms.maps.GoogleMap;
    import com.google.android.gms.maps.OnMapReadyCallback;
    import com.google.android.gms.maps.SupportMapFragment;
    
    public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            SupportMapFragment mapFragment = new SupportMapFragment();
            mapFragment.getMapAsync(this);
            getSupportFragmentManager()
                    .beginTransaction()
                    .replace(R.id.fragment_container, mapFragment)
                    .commit();
    
        }
    
        @Override
        public void onMapReady(GoogleMap googleMap) {
    
        }
    }
    

  • answered 2018-01-14 10:00 Yupi

    Your exception is caused by:

    Resources$NotFoundException: Resource ID #0x7f080013 type #0x6 is not valid at android.content.res.Resources.getDimensionPixelSize(Resources.java:697)

    Take a look into code how you use SupportMapFragment did you set it correctly to connect to GoogleMaps. And still if you can not find the issue you could take a look into R generated class and see on what ID is pointing out.