点击运行5.1.1的Oppo F1S中的TextInputLayout崩溃

时间:2018-06-06 09:44:44

标签: android android-layout android-textinputlayout textinputlayout

点击TextInputLayout后,应用程序在运行5.1.1的Oppo F1S中延迟1秒后崩溃。我无法访问设备拳头我遇到了崩溃报告的崩溃,然后我让我的远程朋友在他们的oppo手机上试用它。

我无法找出原因,而且由于我无法访问该设备,我发现它非常难以解决问题。

它在其他设备上工作正常,甚至在运行8.1.0的oppoF7

这是我的XML

   <android.support.design.widget.TextInputLayout
            android:id="@+id/til_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="24dp"
            android:layout_marginStart="24dp"
            android:layout_marginTop="32dp"
            android:theme="@style/TextLabel"
            app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="1.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView53">

            <android.support.v7.widget.AppCompatEditText
                android:id="@+id/et_email"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#00000000"
                android:drawablePadding="10dp"
                android:hint="Email"
                android:inputType="textEmailAddress"
                android:onTextChanged="@{(text, start, before, count) -> activity.onEmailChanged(text)}"
                android:paddingTop="10dp"
                app:backgroundTint="@color/black" />
        </android.support.design.widget.TextInputLayout>

这是styles.xml

<!--Input field style-->
    <style name="MyEditText" parent="Theme.AppCompat.Light">
        <item name="colorControlNormal">@color/black</item>
        <item name="colorControlActivated">@color/black</item>
        <item name="android:textColorHint">@color/greish</item>
        <item name="android:textSize">14sp</item>
        <item name="colorAccent">@color/black</item>
    </style>
    <style name="ErrorText" parent="TextAppearance.AppCompat">
        <item name="android:textStyle">bold|italic</item>
        <item name="android:textColor">@color/colorPrimary</item>
    </style>

    <style name="TextLabel" parent="TextAppearance.AppCompat">



 <style name="TextAppearance.App.TextInputLayout" parent="@android:style/TextAppearance">
        <item name="android:textColor">@color/greish</item>
        <item name="android:textSize">12sp</item>
    </style>

Stacktrace 1

Fatal Exception: android.view.InflateException: Binary XML file line #42: Error inflating class TextView
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
   at android.widget.OppoCursorController$FloatPanelViewController.<init>(OppoCursorController.java:1585)
   at android.widget.OppoCursorController.createFloatPanelViewController(OppoCursorController.java:134)
   at android.widget.OppoCursorController$SelectionModifierCursorController.<init>(OppoCursorController.java:518)
   at android.widget.OppoCursorController.create(OppoCursorController.java:81)
   at android.widget.OppoEditor.getOppoSelectionController(OppoEditor.java:417)
   at android.widget.OppoEditor.onTouchEventWrap(OppoEditor.java:322)
   at android.widget.TextView.onTouchEvent(TextView.java:8189)
   at android.view.View.dispatchTouchEvent(View.java:8472)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2440)
   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1748)
   at android.app.Activity.dispatchTouchEvent(Activity.java:2840)
   at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2379)
   at android.view.View.dispatchPointerEvent(View.java:8667)
   at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4446)
   at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4234)
   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3767)
   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3830)
   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3786)
   at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3913)
   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3794)
   at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3970)
   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3767)
   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3830)
   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3786)
   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3794)
   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3767)
   at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6165)
   at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6139)
   at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6110)
   at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6255)
   at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:218)
   at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
   at android.os.MessageQueue.next(MessageQueue.java:150)
   at android.os.Looper.loop(Looper.java:139)
   at android.app.ActivityThread.main(ActivityThread.java:5541)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

Stacktrace 2:

Caused by java.lang.RuntimeException: Failed to resolve attribute at index 24
   at android.content.res.TypedArray.getColor(TypedArray.java:401)
   at android.widget.TextView.<init>(TextView.java:709)
   at android.widget.TextView.<init>(TextView.java:645)
   at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:75)
   at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:71)
   at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
   at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
   at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
   at android.widget.OppoCursorController$FloatPanelViewController.<init>(OppoCursorController.java:1585)
   at android.widget.OppoCursorController.createFloatPanelViewController(OppoCursorController.java:134)
   at android.widget.OppoCursorController$SelectionModifierCursorController.<init>(OppoCursorController.java:518)
   at android.widget.OppoCursorController.create(OppoCursorController.java:81)
   at android.widget.OppoEditor.getOppoSelectionController(OppoEditor.java:417)
   at android.widget.OppoEditor.onTouchEventWrap(OppoEditor.java:322)
   at android.widget.TextView.onTouchEvent(TextView.java:8189)
   at android.view.View.dispatchTouchEvent(View.java:8472)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2417)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2050)
   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2440)
   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1748)
   at android.app.Activity.dispatchTouchEvent(Activity.java:2840)
   at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2379)
   at android.view.View.dispatchPointerEvent(View.java:8667)
   at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4446)
   at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4234)
   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3767)
   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3830)
   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3786)
   at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3913)
   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3794)
   at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3970)
   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3767)
   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3830)
   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3786)
   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3794)
   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3767)
   at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6165)
   at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6139)
   at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6110)
   at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6255)
   at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:218)
   at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
   at android.os.MessageQueue.next(MessageQueue.java:150)
   at android.os.Looper.loop(Looper.java:139)
   at android.app.ActivityThread.main(ActivityThread.java:5541)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

任何想法可能是什么问题?(我无法访问该设备,我从崩解剂中获得了堆栈跟踪)

任何帮助将不胜感激。

3 个答案:

答案 0 :(得分:3)

使用android.support.v7.widget.AppCompatEditText而不是Edittext并且不要使用android:onclick属性,它会在lolipop设备上崩溃。

答案 1 :(得分:0)

问题是Failed to resolve attribute at index 24;造成原因:

<style name="MyEditText" parent="Theme.AppCompat.Light">

a)必须将其替换为继承Widget.Design.TextInputLayout的样式:

<style name="MyEditText" parent="Widget.Design.TextInputLayout">

b)或使用com.google.android.material.textfield.TextInputLayout作为explained here;这将需要一种匹配样式,该样式继承Base.Widget.MaterialComponents.TextInputLayout

始终继承组件随附的样式,以避免出现此类问题。

答案 2 :(得分:0)

我在某些方面有完全相同的问题。在我的情况下,解决方案是将hint放在TextInputLayout中,而 NOT 放在EditText