Wednesday, 5 May 2021

android.view.InflateException: Binary XML file CheckBox

I have published an application and I see that some users keep getting errors when they are in the sign-up activity.

The error I'm getting is:

Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{com.xxx.yyy/com.xxx.yyy.SignUpActivity}: android.view.InflateException: Binary XML file line #137 in com.xxx.yyy:layout/activity_sign_up: Binary XML file line #137 in com.xxx.yyy:layout/activity_sign_up: Error inflating class CheckBox

When I go to layout/activity_sign_up to line 137 I got this:

<CheckBox
    android:id="@+id/cb_showPass"
    android:layout_width="32dp"
    android:layout_height="32dp"
    android:background="@drawable/cb_visible_styles"
    android:button="@null"
    android:scaleX="0.6"
    android:scaleY="0.6"
    app:layout_constraintBottom_toBottomOf="@+id/et_SignUpPassword"
    app:layout_constraintEnd_toEndOf="@+id/et_SignUpPassword"
    app:layout_constraintTop_toTopOf="@+id/et_SignUpPassword" />

Which is used to show the eye in the EditText:

enter image description here

The drawable/cb_visible_styles is:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/cb_show" android:state_checked="false" />
    <item android:drawable="@drawable/cb_hide" android:state_checked="true" />
    <item android:drawable="@drawable/cb_show" />
</selector>

Where cb_show/cb_hide are png files:

enter image description here

I can't figure out what causes the error. Some places say it is because of Scaling, some say it is because of Density, Can't figure out why for many users it is fine but for a specific few it doesn't.

One time it appeared on Samsung S21, the other at Nexus 5X. One time on Android 10 and the other on Android 8.1.

Thank you



from android.view.InflateException: Binary XML file CheckBox

No comments:

Post a Comment