android.view.InflateException:二进制XML文件行#0:错误类膨胀

时间:2018-05-07 09:32:28

标签: android xml android-constraintlayout inflate-exception

谁能告诉我这个布局有什么问题?因为我似乎无法找到任何可能导致InflateException的异常情况。此外,我主要在三星设备上获得此例外,其他人似乎或多或少都有效。完全例外

  

致命异常:java.lang.RuntimeException   无法启动活动ComponentInfo {类名}:android.view.InflateException:二进制XML文件行#0:错误导致{类名}

 <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout   
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/loginContainer"
    style="@style/AuthenticationTheme"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:alpha="0">

    <LinearLayout
        android:id="@+id/holder"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:gravity="center"
            android:text="@string/window_enter_identifier_greeting_label"
            android:textAlignment="center"
            android:textSize="26sp" />

        <TextView
            android:id="@+id/info"
            style="@style/AuthenticationTheme"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_marginLeft="@dimen/authentication_margin_from_sides"
            android:layout_marginRight="@dimen/authentication_margin_from_sides"
            android:gravity="center"
            android:text="@string/window_enter_identifier_phone_description_label"
            android:textAlignment="center"
            android:textSize="16sp" />

        <LinearLayout
            android:id="@+id/phoneInputHolder"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.custom.authentication.views.IdentifierInputView
                android:id="@+id/authenticationInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/authentication_margin_from_sides"
                android:layout_marginRight="@dimen/authentication_margin_from_sides" />

        </LinearLayout>
    </LinearLayout>

    <com.custom.authentication.views.BottomButtonsView
        android:id="@+id/bottomButtons"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:linkText="@string/window_enter_identifier_login_with_email_button"
        app:mainText="@string/Continue" />

</android.support.constraint.ConstraintLayout>

我在我的自定义视图类中扩充此布局,如下所示:

class EnterIdentifierView(context: Context) : ConstraintLayout(context) {

    init {
        inflate(context, R.layout.view_enter_identifier, this)

    }    

创建我的自定义视图:

override fun onCreateControllerView(layoutInflater: LayoutInflater, viewParent: ViewGroup) = EnterIdentifierView(layoutInflater.context)

1 个答案:

答案 0 :(得分:0)

我不认为这是一个答案,更多的是一个建议,但因为我没有足够的声誉,所以必须这样做。

根据我的经验,当我收到此类错误时,有时会显示OutOfMemory错误,请检查以确保您的自定义类不会尝试加载任何大图像等。

如果您有权访问任何OOM,请仔细检查完整的Stacktrace