Android 二进制XML文件行#17:膨胀类时出错<;未知>;-不可预测的错误

Android 二进制XML文件行#17:膨胀类时出错<;未知>;-不可预测的错误,android,android-inflate,iunknown,Android,Android Inflate,Iunknown,我试图在getView(…)方法中将版面膨胀到自定义适配器,但有时会在标题中出错。我已经尝试在这里搜索类似的问题,但我没有找到一个适合我的解决方案。这个错误很奇怪,因为它只是偶尔发生,而且只发生在一些设备上——下面是完整的日志 android.view.InflateException: Binary XML file line #17: Error inflating class <unknown> at android.view.LayoutInflate

我试图在
getView(…)
方法中将版面膨胀到自定义适配器,但有时会在标题中出错。我已经尝试在这里搜索类似的问题,但我没有找到一个适合我的解决方案。这个错误很奇怪,因为它只是偶尔发生,而且只发生在一些设备上——下面是完整的日志

android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
            at android.view.LayoutInflater.createView(LayoutInflater.java:606)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
            at cz.anywhere.sochi.adapter.NewsAdapter.getView(NewsAdapter.java:35)
            at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
            at android.widget.AbsListView.obtainView(AbsListView.java:2040)
            at android.widget.ListView.makeAndAddView(ListView.java:1772)
            at android.widget.ListView.fillDown(ListView.java:672)
            at android.widget.ListView.fillSpecific(ListView.java:1330)
            at android.widget.ListView.layoutChildren(ListView.java:1603)
            at android.widget.AbsListView.onLayout(AbsListView.java:1870)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1415)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1589)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1415)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:690)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1415)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
            at android.view.View.layout(View.java:11418)
            at android.view.ViewGroup.layout(ViewGroup.java:4328)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1489)
            at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.L
item_news.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:padding="10dp"
        android:layout_height="130dp">

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/news_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/dummy_image" />

            <ProgressBar
                android:id="@+id/news_progress"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true" />

        </RelativeLayout>


        <RelativeLayout
            android:layout_width="0dp"
            android:layout_weight="2"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingLeft="10dp"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/news_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/newsTitle"
                    android:text="@string/dummy_text" />


                <TextView
                    android:id="@+id/news_date"
                    android:text="@string/dummy_text"
                    android:layout_marginTop="5dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />


            </LinearLayout>

            <ImageView
                android:id="@+id/news_source_logo"
                android:adjustViewBounds="true"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="5dp"
                android:layout_marginRight="5dp"
                android:layout_width="15dp"
                android:src="@drawable/exclusive_logo"
                android:layout_height="wrap_content" />


        </RelativeLayout>


    </LinearLayout>

</RelativeLayout>

该错误发生在
@+id/news\u image
ImageView上,但它的出现是不可预测的,并且仅出现在某些设备上(在使用Android 4.3的Galaxy S4上,一切正常,但在Galaxy S3上,Android 4.1.2应用程序有时会因该错误而崩溃)


感谢您的帮助。

日志猫中应该有一个内部“起因”异常-将其包含在问题中。此外,您的视图层次结构看起来很深,这使得应用程序容易出现堆栈溢出。这是模糊的,但是您可以尝试用LayoutInflater上下文替换getInflater()。getSystemService代码吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:padding="10dp"
        android:layout_height="130dp">

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/news_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/dummy_image" />

            <ProgressBar
                android:id="@+id/news_progress"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true" />

        </RelativeLayout>


        <RelativeLayout
            android:layout_width="0dp"
            android:layout_weight="2"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingLeft="10dp"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/news_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/newsTitle"
                    android:text="@string/dummy_text" />


                <TextView
                    android:id="@+id/news_date"
                    android:text="@string/dummy_text"
                    android:layout_marginTop="5dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />


            </LinearLayout>

            <ImageView
                android:id="@+id/news_source_logo"
                android:adjustViewBounds="true"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="5dp"
                android:layout_marginRight="5dp"
                android:layout_width="15dp"
                android:src="@drawable/exclusive_logo"
                android:layout_height="wrap_content" />


        </RelativeLayout>


    </LinearLayout>

</RelativeLayout>