android.view.InflateException: бинарный XML-файл, строка № 0: ошибка надувания класса - PullRequest
0 голосов
/ 07 мая 2018

Может кто-нибудь сказать мне, что не так с этим макетом? Потому что я не могу найти ничего необычного, что может вызвать InflateException. Также я получаю это исключение в основном на устройствах Samsung, другие, кажется, работают более или менее нормально. Полное исключение

Фатальное исключение: 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 голосов
/ 07 мая 2018

Я не думаю, что это ответ, скорее предложение, но поскольку у меня недостаточно репутации, я должен опубликовать его как таковой.

Исходя из моего опыта, когда я получаю ошибку такого типа, она иногда указывает на ошибку OutOfMemory, убедитесь, что ваши пользовательские классы не пытаются загружать большие изображения и т. Д.

Также внимательно проверьте полную Stacktrace, если у вас есть доступ к ней, для любых OOM

...