Android崩溃 - FileNotFoundException:损坏的XML二进制文件

时间:2016-11-04 10:48:07

标签: android xml android-layout exception filenotfoundexception

我最近在同一个屏幕上从一个特定设备收到了6个FileNotFoundException(@CrashActivity:onCreate:135){main}。

  

java.lang.RuntimeException:无法启动活动   ComponentInfo {com。示例/ com.example.CrashActivity}:   android.content.res.Resources $ NotFoundException:File   来自xml类型布局资源ID的 res / layout / crash_layout.xml #0x7f03006d   在   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2299)   在   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)   在android.app.ActivityThread.access $ 800(ActivityThread.java:151)at   android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1243)   在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)   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:786)at   dalvik.system.NativeStart.main(Native方法)引起:   android.content.res.Resources $ NotFoundException:File   来自xml类型布局资源ID的 res / layout / crash_layout.xml #0x7f03006d   在   android.content.res.Resources.loadXmlResourceParser(Resources.java:2449)   在   android.content.res.Resources.loadXmlResourceParser(Resources.java:2404)   在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)   在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)   在   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2239)   ... 11更多引起:java.io.FileNotFoundException:损坏的XML   二进制文件   android.content.res.AssetManager.openXmlAssetNative(Native Method)at   android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:502)   在   android.content.res.Resources.loadXmlResourceParser(Resources.java:2431)   ......还有25个

我的Android应用程序已锁定为纵向模式。

<activity
            android:name="com.example.CrashActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.Styled"
            android:exported="true"> </activity>

据报道 的setContentView(R.layout.crash_screen); 在CrashActivity的onCreate(..)中 其中 crash_screen.xml 是CrashActivity的布局。 crash_screen.xml 依次包含已报告丢失的 crash_layout.xml 。 我已经检查了R.java的资源ID#0x7f03006d,它指向crash_layout.xml 这是我收到此崩溃的唯一实例,并且最近几个版本中的相应活动和布局中没有代码更改。

完整的代码非常大,所以我添加了报告崩溃的代码。

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);
...

crash_screen.xml

<?xml version="1.0" encoding="utf-8"?>
<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" >

    <LinearLayout
        android:id="@+id/layoutInclude2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:visibility="visible"
         >

        <include layout="@layout/crash_layout" />
    </LinearLayout>

    <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" />

    <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" />

<ProgressBar
             android:id="@+id/globalprogressBar"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content" 
             android:layout_gravity="center_horizontal"
             android:visibility="gone"/>
     <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">
    </com.exampleApp.pulltorefresh.library.PullToRefreshListView>

      <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" />

    <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" >

        <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" />

        <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" />

        <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"/>
    </LinearLayout>

    <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" />

</LinearLayout>

crash_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<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"
     >
    <RelativeLayout 
        android:id="@+id/tab_top_layout"
         android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:background="@color/white"
     android:orientation="vertical">

        <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"
            >
        <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"/>

        <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"/>

        <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"/>
</RelativeLayout>
    </RelativeLayout>

    <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"
         >

        <RelativeLayout
            android:id="@+id/xyz"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="22" >

            <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"/>

            <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" />

             <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"
            />

        </RelativeLayout>

       <RelativeLayout
            android:id="@+id/abc"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
             android:layout_weight="22" >

            <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" />

            <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" />

             <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" />

        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/deals"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="22"
            android:visibility="invisible">

            <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" />

            <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" />

            <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" />

        </RelativeLayout>
         <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:src="@drawable/screen_logo" 
             android:layout_weight="12"/>





            <RelativeLayout
            android:id="@+id/profile"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
             android:layout_weight="22" >

            <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" />

            <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"/>

             <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"/>

        </RelativeLayout>

    </LinearLayout>
 <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"/>


</RelativeLayout>

0 个答案:

没有答案