android.view.InflateException:错误膨胀类 android.widget.EditText ASUS Android 5 [英] android.view.InflateException: Error inflating class android.widget.EditText ASUS Android 5

查看:74
本文介绍了android.view.InflateException:错误膨胀类 android.widget.EditText ASUS Android 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到有关此崩溃发生的报告,但它仅发生在使用 android 5 的 asus 设备上,如下图所示

I'm getting constant reports of this crash happening, but it only happens on asus devices, with android 5, as the image below shows

这是堆栈跟踪:

    Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my_package/com.my_package.activities.SignInActivity}: android.view.InflateException: Binary XML file line #29: Error inflating class android.widget.EditText
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2326)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
       at android.app.ActivityThread.access$800(ActivityThread.java:147)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5264)
       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:900)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
Caused by android.view.InflateException: Binary XML file line #29: Error inflating class android.widget.EditText
       at android.view.LayoutInflater.createView(LayoutInflater.java:633)
       at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
       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.view.View.inflate(View.java:18427)
       at com.my_package.activities.SignInActivity.onCreate(SignInActivity.java:52)
       at android.app.Activity.performCreate(Activity.java:5975)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
       at android.app.ActivityThread.access$800(ActivityThread.java:147)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5264)
       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:900)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
Caused by java.lang.reflect.InvocationTargetException
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:607)
       at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
       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.view.View.inflate(View.java:18427)
       at com.my_package.activities.SignInActivity.onCreate(SignInActivity.java:52)
       at android.app.Activity.performCreate(Activity.java:5975)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
       at android.app.ActivityThread.access$800(ActivityThread.java:147)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5264)
       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:900)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
Caused by java.lang.RuntimeException: Failed to resolve attribute at index 96
       at android.content.res.TypedArray.getColor(TypedArray.java:401)
       at android.widget.TextView.<init>(TextView.java:714)
       at android.widget.EditText.<init>(EditText.java:65)
       at android.widget.EditText.<init>(EditText.java:61)
       at android.widget.EditText.<init>(EditText.java:57)
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:607)
       at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
       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.view.View.inflate(View.java:18427)

SignInActivity.java

@Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_in);

        llSignInContainer = (LinearLayout) findViewById(R.id.llSignInContainer);
        llSignInContainer.addView(View.inflate(this, R.layout.sign_in_form, null)); // <-- Line 52
    }

sign_in_form.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_below="@+id/rlTop"
    android:background="@android:color/white"
    android:orientation="vertical"
    android:padding="@dimen/activity_horizontal_margin">

    <TextView
        android:id="@+id/tvHeader"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/activity_horizontal_margin"
        android:layout_marginTop="@dimen/activity_horizontal_margin"
        android:padding="@dimen/edit_text_padding"
        android:text="@string/type_data_to_access_central"
        android:textColor="@color/mediumGray" />

    <android.support.design.widget.TextInputLayout
        android:id="@+id/inputEmail"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/TextInputStyle"
        app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout"
        app:passwordToggleEnabled="false">

        <EditText // -- This is line 29 --
            android:id="@+id/etEmail"
            style="@style/FormEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/your_email"
            android:inputType="textEmailAddress" />
    </android.support.design.widget.TextInputLayout>

在其他设备上它工作正常,我在华硕设备上测试了 android 4.3 和 6.0,它也工作正常.

On other devices it works fine, and I tested with ASUS devices with android 4.3 and 6.0 and it also works fine.

推荐答案

如本回答评论中所说https://stackoverflow.com/a/30914037/5178257问题出在主题上,因此如果您将父主题设置为 ThemeOverlay.AppCompat.Light,它将解决华硕设备上的崩溃问题.

As said on the comments of this answer https://stackoverflow.com/a/30914037/5178257 the problem is with the theme, so if you set the parent theme to ThemeOverlay.AppCompat.Light it'll solve the crashes on ASUS devices.

例如

<style name="TextInputStyle" parent="ThemeOverlay.AppCompat.Light">
  <item name="android:textColorHint">@color/black</item>     
  <item name="colorControlActivated">@color/gray</item>
</style>

这篇关于android.view.InflateException:错误膨胀类 android.widget.EditText ASUS Android 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆