Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to inflate ColorStateList on a TextInputLayout

I'm trying to make a login screen with TextInputLayouts. But I can't get errors to be shown. I'm getting the next error on the LogCat and the errors doesn't appear.

E/AppCompatResources: Failed to inflate ColorStateList, leaving it to the framework
java.lang.UnsupportedOperationException: Can't convert to color: type=0x2

I have some of the next components.

<android.support.design.widget.TextInputLayout
            android:id="@+id/til_email"
            android:layout_width="match_parent"
            android:layout_height="@dimen/textinput_height">

            <android.support.v7.widget.AppCompatEditText
                android:id="@+id/et_email"
                android:layout_width="match_parent"
                android:layout_height="@dimen/textinput_height"
                android:drawableLeft="@drawable/ic_face"
                android:drawableStart="@drawable/ic_face"
                android:drawablePadding="8dp"
                android:hint="@string/str_email"
                android:imeOptions="actionNext"
                android:inputType="textEmailAddress"
                android:textColor="@color/blue"
                android:typeface="normal" />
        </android.support.design.widget.TextInputLayout>

I don't know how to solve this fail. Can anybody tell me some advise with this?

Thank you.

Stacktrace

06-22 09:26:46.897 1853-1853/com.ikomobi.SuscribeApp E/AppCompatResources: Failed to inflate ColorStateList, leaving it to the framework
                                                                           java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
                                                                               at android.content.res.TypedArray.getColor(TypedArray.java:326)
                                                                               at android.support.v7.content.res.AppCompatColorStateListInflater.inflate(AppCompatColorStateListInflater.java:114)
                                                                               at android.support.v7.content.res.AppCompatColorStateListInflater.createFromXmlInner(AppCompatColorStateListInflater.java:88)
                                                                               at android.support.v7.content.res.AppCompatColorStateListInflater.createFromXml(AppCompatColorStateListInflater.java:67)
                                                                               at android.support.v7.content.res.AppCompatResources.inflateColorStateList(AppCompatResources.java:116)
                                                                               at android.support.v7.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:74)
                                                                               at android.support.v7.widget.TintTypedArray.getColorStateList(TintTypedArray.java:136)
                                                                               at android.support.v7.widget.AppCompatTextHelper.onSetTextAppearance(AppCompatTextHelper.java:157)
                                                                               at android.support.v7.widget.AppCompatTextView.setTextAppearance(AppCompatTextView.java:148)
                                                                               at android.support.v4.widget.TextViewCompatGingerbread.setTextAppearance(TextViewCompatGingerbread.java:103)
                                                                               at android.support.v4.widget.TextViewCompat$BaseTextViewCompatImpl.setTextAppearance(TextViewCompat.java:86)
                                                                               at android.support.v4.widget.TextViewCompat.setTextAppearance(TextViewCompat.java:283)
                                                                               at android.support.design.widget.TextInputLayout.setErrorEnabled(TextInputLayout.java:609)
                                                                               at com.ikomobi.SuscribeApp.ui.login.LoginFragment.setUp(LoginFragment.java:81)
                                                                               at com.ikomobi.SuscribeApp.ui.login.LoginFragment.onCreateView(LoginFragment.java:73)
                                                                               at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
                                                                               at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
                                                                               at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
                                                                               at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
                                                                               at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
                                                                               at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
                                                                               at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
                                                                               at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
                                                                               at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
                                                                               at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
                                                                               at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
                                                                               at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
                                                                               at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
                                                                               at android.app.Activity.performStart(Activity.java:5018)
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
                                                                               at android.app.ActivityThread.access$600(ActivityThread.java:130)
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                               at android.os.Looper.loop(Looper.java:137)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                               at java.lang.reflect.Method.invokeNative(Native Method)
                                                                               at java.lang.reflect.Method.invoke(Method.java:511)
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                               at dalvik.system.NativeStart.main(Native Method)
06-22 09:26:46.897 1853-1853/com.ikomobi.SuscribeApp E/AppCompatResources: Failed to inflate ColorStateList, leaving it to the framework
                                                                           java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
                                                                               at android.content.res.TypedArray.getColor(TypedArray.java:326)
                                                                               at android.support.v7.content.res.AppCompatColorStateListInflater.inflate(AppCompatColorStateListInflater.java:114)
                                                                               at android.support.v7.content.res.AppCompatColorStateListInflater.createFromXmlInner(AppCompatColorStateListInflater.java:88)
                                                                               at android.support.v7.content.res.AppCompatColorStateListInflater.createFromXml(AppCompatColorStateListInflater.java:67)
                                                                               at android.support.v7.content.res.AppCompatResources.inflateColorStateList(AppCompatResources.java:116)
                                                                               at android.support.v7.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:74)
                                                                               at android.support.v7.widget.TintTypedArray.getColorStateList(TintTypedArray.java:136)
                                                                               at android.support.v7.widget.AppCompatTextHelper.onSetTextAppearance(AppCompatTextHelper.java:157)
                                                                               at android.support.v7.widget.AppCompatTextView.setTextAppearance(AppCompatTextView.java:148)
                                                                               at android.support.v4.widget.TextViewCompatGingerbread.setTextAppearance(TextViewCompatGingerbread.java:103)
                                                                               at android.support.v4.widget.TextViewCompat$BaseTextViewCompatImpl.setTextAppearance(TextViewCompat.java:86)
                                                                               at android.support.v4.widget.TextViewCompat.setTextAppearance(TextViewCompat.java:283)
                                                                               at android.support.design.widget.TextInputLayout.setErrorEnabled(TextInputLayout.java:609)
                                                                               at com.ikomobi.SuscribeApp.ui.login.LoginFragment.setUp(LoginFragment.java:82)
                                                                               at com.ikomobi.SuscribeApp.ui.login.LoginFragment.onCreateView(LoginFragment.java:73)
                                                                               at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
                                                                               at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
                                                                               at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
                                                                               at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
                                                                               at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
                                                                               at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
                                                                               at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
                                                                               at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
                                                                               at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
                                                                               at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
                                                                               at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
                                                                               at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
                                                                               at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
                                                                               at android.app.Activity.performStart(Activity.java:5018)
                                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
                                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
                                                                               at android.app.ActivityThread.access$600(ActivityThread.java:130)
                                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                               at android.os.Looper.loop(Looper.java:137)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                               at java.lang.reflect.Method.invokeNative(Native Method)
                                                                               at java.lang.reflect.Method.invoke(Method.java:511)
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                               at dalvik.system.NativeStart.main(Native Method)
like image 493
Víctor Martín Avatar asked Jun 22 '17 07:06

Víctor Martín


1 Answers

I had the same error when using TextInputLayout, and setting errorEnabled

I resolved it by adding a textColorError to my custom App theme:

<style name="YOURCUSTOMTHEME" parent="YOUR.PARENT.THEME">
     <!-- ..... other styles -->
     <item name="textColorError">@color/YOUR_COLOR</item>
</style>
like image 125
medhdj Avatar answered Nov 15 '22 16:11

medhdj