I am getting tired of fixing this problem. Always show me this error
Binary XML file line #11: Error inflating class EditText.
I don’t understand how to fix this problem. Already tried many StackOverflow answers but failed.
Using Gradle 7.1.0 version. Device Pixel 4 API 27.
XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/PrimaryLight"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="@+id/etID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_marginRight="15dp"
android:ems="10"
android:gravity="center_horizontal"
android:hint="@string/hint_id"
android:inputType="number"
android:minHeight="48dp"
android:textColorHint="@color/material_dynamic_neutral10"
android:importantForAutofill="no" />
</LinearLayout>
Error message:
2022-02-02 17:05:04.720 9809-9809/com.example.magicidapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.magicidapplication, PID: 9809
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.magicidapplication/com.example.magicidapplication.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class EditText
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class EditText
Caused by: java.lang.UnsupportedOperationException: Can't convert to ComplexColor: type=0x1
2
Answers
you have issue in your color. try changing color
android:textColorHint="@color/material_dynamic_neutral10"
As pointed out by the stacktrace
Caused by: java.lang.UnsupportedOperationException: Can't convert to ComplexColor: type=0x1
there is some issue in the@color/material_dynamic_neutral10
color change it to something else or remove it