Android Crash - FileNotFoundException: Corrupt XML binary file
<p>I recently received 6 FileNotFoundException (@CrashActivity:onCreate:135) {main} from one particular device on the same screen.</p>

<blockquote>
  <p>java.lang.RuntimeException: Unable to start activity
  ComponentInfo{com.example/com.example.CrashActivity}:
  android.content.res.Resources$NotFoundException: File
  <strong>res/layout/crash_layout.xml</strong> from xml type layout resource ID #0x7f03006d
  at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2299)
  at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
  at android.app.ActivityThread.access$800(ActivityThread.java:151) at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
  at android.os.Handler.dispatchMessage(Handler.java:102) at
  android.os.Looper.loop(Looper.java:136) at
  android.app.ActivityThread.main(ActivityThread.java:5372) at
  java.lang.reflect.Method.invokeNative(Native Method) at
  java.lang.reflect.Method.invoke(Method.java:515) at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:970)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:786) at
  dalvik.system.NativeStart.main(Native Method) Caused by:
  android.content.res.Resources$NotFoundException: File
  <strong>res/layout/crash_layout.xml</strong> from xml type layout resource ID #0x7f03006d
  at
  android.content.res.Resources.loadXmlResourceParser(Resources.java:2449)
  at
  android.content.res.Resources.loadXmlResourceParser(Resources.java:2404)
  at android.content.res.Resources.getLayout(Resources.java:955) at
  android.view.LayoutInflater.parseInclude(LayoutInflater.java:794) at
  android.view.LayoutInflater.rInflate(LayoutInflater.java:745) at
  android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at
  android.view.LayoutInflater.inflate(LayoutInflater.java:492) at
  android.view.LayoutInflater.inflate(LayoutInflater.java:397) at
  android.view.LayoutInflater.inflate(LayoutInflater.java:353) at
  com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:296)
  at android.app.Activity.setContentView(Activity.java:1935) at
  com.example.CrashActivity.onCreate(SourceFile:135) at
  android.app.Activity.performCreate(Activity.java:5258) at
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1099)
  at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2239)
  ... 11 more Caused by: java.io.FileNotFoundException: Corrupt XML
  binary file at
  android.content.res.AssetManager.openXmlAssetNative(Native Method) at
  android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:502)
  at
  android.content.res.Resources.loadXmlResourceParser(Resources.java:2431)
  ... 25 more</p>
</blockquote>

<p>My android app is locked in portrait mode.</p>

<pre class="lang-xml prettyprint-override"><code>&lt;activity
            android:name="com.example.CrashActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.Styled"
            android:exported="true"&gt; &lt;/activity&gt;
</code></pre>

<p>It is reported on the line
<em>setContentView(R.layout.crash_screen);</em>
in onCreate(..) of the CrashActivity
where <strong>crash_screen.xml</strong> is the layout for the CrashActivity.
<strong>crash_screen.xml</strong> in-turn includes <strong>crash_layout.xml</strong> which has been reported to be missing.
I have checked the R.java for resource ID #0x7f03006d and it points to crash_layout.xml
This is the only instance where I have received this crash and also there has been no code change in the respective activities and layouts in the last few releases.</p>

<p>The complete code is very big so I am adding the code around which the crash was reported.</p>

<pre><code>protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.crash_screen);
    easyTracker = EasyTracker.getInstance(CrashActivity.this);
    ApplicationSettings.putPref(AppConstants.LAST_COUNT, "0");
    crashScreen = this;
    tf = Typeface.createFromAsset(this.getAssets(), "fonts/RobotoRegular.ttf");
    actionbarTitle = (TextView) findViewById(R.id.title);
    actionbarSubtitle = (TextView) findViewById(R.id.subtitle);

    searchEditText = (EditText) findViewById(R.id.searchedittext);
    searchEditText.setTypeface(tf);

    dialog = new Dialog(HospitalsActivity.this);
...
</code></pre>

<p>crash_screen.xml
</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:orientation="vertical" &gt;

    &lt;LinearLayout
        android:id="@+id/layoutInclude2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:visibility="visible"
         &gt;

        &lt;include layout="@layout/crash_layout" /&gt;
    &lt;/LinearLayout&gt;

    &lt;TextView
        android:id="@+id/gp_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="10dp"
        android:text="@string/xyzs"
        android:textColor="@android:color/black"
        android:textSize="18sp"
        android:visibility="gone" /&gt;

    &lt;com.exampleApp.utils.MyEditText
        android:id="@+id/searchedittext"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:hint="@string/hint_xyz"
        android:imeOptions="actionSearch"
        android:textSize="14sp"
        android:singleLine="true" /&gt;

&lt;ProgressBar
             android:id="@+id/globalprogressBar"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content" 
             android:layout_gravity="center_horizontal"
             android:visibility="gone"/&gt;
     &lt;com.exampleApp.pulltorefresh.library.PullToRefreshListView
        xmlns:ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/xyzListView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_margin="5dp"
        android:cacheColorHint="@android:color/transparent"
        android:divider="#FFFFFF"
        android:dividerHeight="1dp"
        android:listSelector="@android:color/transparent"
        android:overScrollMode="never"
        ptr:ptrShowIndicator="false"
        android:scrollbars="none" 
        android:visibility="visible"&gt;
    &lt;/com.exampleApp.pulltorefresh.library.PullToRefreshListView&gt;

      &lt;ListView
                android:id="@+id/globalListView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/searchLayout"
                android:layout_centerInParent="true"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:background="@color/white"
                android:choiceMode="singleChoice"
                android:divider="@null"
                android:dividerHeight="0dp"
                android:listSelector="@android:color/transparent"
                android:overScrollMode="never"
                android:scrollbars="none"
                android:visibility="gone" /&gt;

    &lt;LinearLayout
        android:id="@+id/layoutNoNetWork"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dip"
        android:layout_marginRight="10dip"
        android:layout_marginTop="20dip"
        android:orientation="vertical"
        android:textColor="@color/lightgrey"
        android:visibility="gone" &gt;

        &lt;TextView
            android:id="@+id/txtNoNetwork"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/No_Network"
            android:textColor="@color/lightgrey"
            android:textSize="20sp" /&gt;

        &lt;TextView
            android:id="@+id/txtNoNetworkDesc"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="@string/No_NetworkDesc"
            android:textColor="@color/lightgrey"
            android:textSize="16sp" /&gt;

        &lt;TextView
            android:id="@+id/refresh"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="35dp"
            android:drawableTop="@drawable/default_ptr_rotate"
            android:text="Refresh"
            android:textColor="@color/lightgrey"
            android:visibility="gone"/&gt;
    &lt;/LinearLayout&gt;

    &lt;TextView
        android:id="@+id/txtNoResultFound"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dip"
        android:gravity="center"
        android:text="@string/No_ResultFound"
        android:textColor="@color/black"
        android:textSize="16sp"
        android:visibility="gone" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>crash_layout.xml
</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:orientation="vertical"
     &gt;
    &lt;RelativeLayout 
        android:id="@+id/tab_top_layout"
         android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:background="@color/white"
     android:orientation="vertical"&gt;

        &lt;RelativeLayout 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:id="@+id/layoutLocation"
            android:paddingTop="@dimen/tab_title_margin"
            android:paddingBottom="@dimen/tab_title_margin"
            &gt;
        &lt;TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Title"
            android:textColor="@color/screen_header"
            android:textSize="@dimen/tab_title_sz" 
            android:layout_centerVertical="true"
            android:layout_marginLeft="@dimen/tab_title_margin"/&gt;

        &lt;TextView
            android:id="@+id/midtitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/title"
            android:text=" - "
            android:textColor="@color/screen_header"
            android:textSize="@dimen/tab_subtitle_sz"
            android:visibility="gone"/&gt;

        &lt;TextView
            android:id="@+id/subtitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/midtitle"
            android:text="Sub title"
            android:textColor="@color/screen_header"
            android:textSize="@dimen/tab_subtitle_sz"
            android:visibility="gone"/&gt;
&lt;/RelativeLayout&gt;
    &lt;/RelativeLayout&gt;

    &lt;LinearLayout
        android:id="@+id/tab_bottom_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tab_top_layout" 
         android:background="@color/white"
        android:weightSum="100"
         android:orientation="horizontal"
         android:paddingLeft="@dimen/tab_bottom_layout_padding"
         android:paddingRight="@dimen/tab_bottom_layout_padding"
         android:layout_marginTop="5dp"
         &gt;

        &lt;RelativeLayout
            android:id="@+id/xyz"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="22" &gt;

            &lt;TextView
                android:id="@+id/xyz_tv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/xyz_iv"
                android:gravity="center"
                android:text="xyzS"
                android:textColor="@color/black"
                android:textSize="@dimen/tab_txt_name_size"
                android:layout_marginTop="@dimen/tab_txt_name_margin" 
                android:layout_marginBottom="@dimen/tab_txt_name_margin"/&gt;

            &lt;ImageView
                android:id="@+id/xyz_iv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:background="@drawable/xyz_off" /&gt;

             &lt;View
                 android:id="@+id/xyz_view"
             android:layout_width="match_parent"
                android:layout_height="3dp"
                android:background="@color/screen_header"
                 android:layout_below="@+id/xyz_tv" 
                 android:visibility="invisible"
            /&gt;

        &lt;/RelativeLayout&gt;

       &lt;RelativeLayout
            android:id="@+id/abc"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
             android:layout_weight="22" &gt;

            &lt;ImageView
                android:id="@+id/abc_iv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
               android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:background="@drawable/abc_off" /&gt;

            &lt;TextView
                android:id="@+id/abc_tv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/abc_iv"
                android:gravity="center"
                android:text="abcS"
                android:textColor="@color/black"
                android:textSize="@dimen/tab_txt_name_size"
                android:layout_marginTop="@dimen/tab_txt_name_margin" 
                android:layout_marginBottom="@dimen/tab_txt_name_margin" /&gt;

             &lt;View
                 android:id="@+id/abc_view"
             android:layout_width="match_parent"
                android:layout_height="3dp"
                android:background="@color/screen_header"
                 android:layout_below="@+id/abc_tv"
                  android:visibility="invisible" /&gt;

        &lt;/RelativeLayout&gt;

        &lt;RelativeLayout
            android:id="@+id/deals"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="22"
            android:visibility="invisible"&gt;

            &lt;ImageView
                android:id="@+id/deals_iv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:background="@drawable/deals_off" /&gt;

            &lt;TextView
                android:id="@+id/deals_tv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/deals_iv"
                android:gravity="center"
                android:text="HEALTHY DEALS"
                android:textColor="@color/black"
                android:textSize="@dimen/tab_txt_name_size"
                android:layout_marginTop="@dimen/tab_txt_name_margin"
                android:layout_marginBottom="@dimen/tab_txt_name_margin" /&gt;

            &lt;View
                android:id="@+id/deals_view"
                android:layout_width="match_parent"
                android:layout_height="3dp"
                android:background="@color/screen_header"
                android:layout_below="@+id/deals_tv"
                android:visibility="invisible" /&gt;

        &lt;/RelativeLayout&gt;
         &lt;RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:src="@drawable/screen_logo" 
             android:layout_weight="12"/&gt;





            &lt;RelativeLayout
            android:id="@+id/profile"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
             android:layout_weight="22" &gt;

            &lt;ImageView
                android:id="@+id/profile_iv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                 android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:background="@drawable/profile_off" /&gt;

            &lt;TextView
                android:id="@+id/profile_tv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/profile_iv"
                android:gravity="center"
                android:text="PROFILE"
                android:textColor="@color/black"
                android:textSize="@dimen/tab_txt_name_size"
                 android:layout_marginTop="@dimen/tab_txt_name_margin" 
                android:layout_marginBottom="@dimen/tab_txt_name_margin"/&gt;

             &lt;View
                 android:id="@+id/profile_view"
             android:layout_width="match_parent"
                android:layout_height="3dp"
                android:background="@color/screen_header"
                 android:layout_below="@+id/profile_tv" 
                  android:visibility="invisible"/&gt;

        &lt;/RelativeLayout&gt;

    &lt;/LinearLayout&gt;
 &lt;LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height=".5dp"
                        android:layout_gravity="center_horizontal"
                        android:background="@color/gary_light" 
                         android:layout_below="@+id/tab_bottom_layout"/&gt;


&lt;/RelativeLayout&gt;
</code></pre>