My Android app is presenting this error when users re-open the app. The first time the app opens normally. It just happen in some devices (sometimes) and I`m not able to solve it. There are some questions about it here in Stackoverflow, but none of them were answered correctly for me.
Here is the full error from Firebase crash:
Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{[REDACTED_DOMAIN_NAME]/com.app.Activities.Activities.PrincipalActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2434)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2494)
android.app.ActivityThread.access$900 (ActivityThread.java:153)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1347)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5451)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)
Caused by android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
android.view.LayoutInflater.inflate (LayoutInflater.java:539)
android.view.LayoutInflater.inflate (LayoutInflater.java:423)
android.view.LayoutInflater.inflate (LayoutInflater.java:374)
com.android.internal.policy.PhoneWindow.setContentView (PhoneWindow.java:393)
android.app.Activity.setContentView (Activity.java:2215)
comwe.app.Activities.Activities.PrincipalActivity.onCreate (PrincipalActivity.java:60)
android.app.Activity.performCreate (Activity.java:6323)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1108)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2387)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2494)
android.app.ActivityThread.access$900 (ActivityThread.java:153)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1347)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5451)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)
Caused by android.view.InflateException: Binary XML file line #11: Error inflating class fragment
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:782)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:704)
android.view.LayoutInflater.rInflate (LayoutInflater.java:835)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:798)
android.view.LayoutInflater.inflate (LayoutInflater.java:515)
android.view.LayoutInflater.inflate (LayoutInflater.java:423)
android.view.LayoutInflater.inflate (LayoutInflater.java:374)
com.android.internal.policy.PhoneWindow.setContentView (PhoneWindow.java:393)
android.app.Activity.setContentView (Activity.java:2215)
com.app.Activities.Activities.PrincipalActivity.onCreate (PrincipalActivity.java:60)
android.app.Activity.performCreate (Activity.java:6323)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1108)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2387)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2494)
android.app.ActivityThread.access$900 (ActivityThread.java:153)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1347)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5451)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)
Caused by java.lang.IllegalStateException: Fragment com.app.Activities.Activities.EmptyFragment did not create a view.
android.support.v4.app.FragmentManagerImpl.onCreateView (FragmentManager.java:3706)
android.support.v4.app.FragmentController.onCreateView (FragmentController.java:111)
android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView (FragmentActivity.java:338)
android.support.v4.app.BaseFragmentActivityApi14.onCreateView (BaseFragmentActivityApi14.java:39)
android.support.v4.app.FragmentActivity.onCreateView (FragmentActivity.java:67)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:754)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:704)
android.view.LayoutInflater.rInflate (LayoutInflater.java:835)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:798)
android.view.LayoutInflater.inflate (LayoutInflater.java:515)
android.view.LayoutInflater.inflate (LayoutInflater.java:423)
android.view.LayoutInflater.inflate (LayoutInflater.java:374)
com.android.internal.policy.PhoneWindow.setContentView (PhoneWindow.java:393)
android.app.Activity.setContentView (Activity.java:2215)
com.app.Activities.Activities.PrincipalActivity.onCreate (PrincipalActivity.java:60)
android.app.Activity.performCreate (Activity.java:6323)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1108)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2387)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2494)
android.app.ActivityThread.access$900 (ActivityThread.java:153)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1347)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5451)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)
Activity:
public class PrincipalActivity extends FragmentActivity {
private FragmentManager fragmentManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_principal);
mFragmentManager = getSupportFragmentManager();
getSupportFragmentManager().beginTransaction().add(R.id.fragment_place, anotherFragment).commit();
Activity XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:design="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_principal2"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.app.Activities.Activities.PrincipalActivity">
<fragment
android:id="@+id/fragment_place"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/divider"
class = "com.app.Activities.Activities.EmptyFragment"
/>
Fragment XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.app.Activities.Activities.EmptyFragment">
</RelativeLayout>
Fragment class:
public class EmptyFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_empty, container, false);
return v;
}
}