Android.view.InflateException: двоичный файл XML, строка № 0: ошибка надувания класса

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

Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{class name}: android.view.InflateException: Binary XML file line #0: Error inflating {class name}

 <?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)

Можете ли вы добавить код, в котором вы пытаетесь раздуть этот макет, нам нужно все это, чтобы помочь вам :).

xoxel 07.05.2018 11:33

@xoxel Я обновил свой пост

Ugnius V 07.05.2018 11:53
1
2
370
1

Ответы 1

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

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

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

Другие вопросы по теме