Android平板电脑版本4.4.2中的类EditText出错导致

时间:2016-10-20 07:01:29

标签: android android-edittext android-4.4-kitkat android-inflate android-textinputlayout

您好我的所有应用程序都运行正常,但我的Android平板电脑崩溃了version 4.4.2,但我不知道为什么应用程序在其他版本中运行良好。我得到的错误:

  

致命异常:java.lang.RuntimeException:无法启动活动   ComponentInfo {}:   android.view.InflateException:二进制XML文件行#38:错误   膨胀类EditText        android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)          在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)          在android.app.ActivityThread.access $ 800(ActivityThread.java:135)          在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1196)          在android.os.Handler.dispatchMessage(Handler.java:102)          在android.os.Looper.loop(Looper.java:136)          在android.app.ActivityThread.main(ActivityThread.java:5017)          at java.lang.reflect.Method.invokeNative(Method.java)          在java.lang.reflect.Method.invoke(Method.java:515)          在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779)          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)          at dalvik.system.NativeStart.main(NativeStart.java)由android.view.InflateException引起:二进制XML文件行#38:错误   膨胀类EditText          在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:755)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:745)          在android.view.LayoutInflater.inflate(LayoutInflater.java:492)          在android.view.LayoutInflater.inflate(LayoutInflater.java:397)          在android.view.LayoutInflater.inflate(LayoutInflater.java:353)          在android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)          在android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)          在android.app.Activity.performCreate(Activity.java:5231)          在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)          在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)          在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)          在android.app.ActivityThread.access $ 800(ActivityThread.java:135)          在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1196)          在android.os.Handler.dispatchMessage(Handler.java:102)          在android.os.Looper.loop(Looper.java:136)          在android.app.ActivityThread.main(ActivityThread.java:5017)          at java.lang.reflect.Method.invokeNative(Method.java)          在java.lang.reflect.Method.invoke(Method.java:515)          在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779)          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)          在dalvik.system.NativeStart.main(NativeStart.java)由java.lang.UnsupportedOperationException引起:无法转换为维度:   类型为0x1 =          在android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:464)          在android.widget.TextView。(TextView.java:972)          在android.widget.EditText。(EditText.java:60)          在android.support.v7.widget.AppCompatEditText。(AppCompatEditText.java:60)          在android.support.v7.widget.AppCompatEditText。(AppCompatEditText.java:56)          在android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:112)          在android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:1008)          在android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1067)          在android.support.v4.view.LayoutInflaterCompatHC $ FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)          在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:755)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)          在android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)          在android.view.LayoutInflater.rInflate(LayoutInflater.java:745)          在android.view.LayoutInflater.inflate(LayoutInflater.java:492)          在android.view.LayoutInflater.inflate(LayoutInflater.java:397)          在android.view.LayoutInflater.inflate(LayoutInflater.java:353)          在android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)          在android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)          在android.app.Activity.performCreate(Activity.java:5231)          在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)          在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)          在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)          在android.app.ActivityThread.access $ 800(ActivityThread.java:135)          在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1196)          在android.os.Handler.dispatchMessage(Handler.java:102)          在android.os.Looper.loop(Looper.java:136)          在android.app.ActivityThread.main(ActivityThread.java:5017)          at java.lang.reflect.Method.invokeNative(Method.java)          在java.lang.reflect.Method.invoke(Method.java:515)          在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779)          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)          在dalvik.system.NativeStart.main(NativeStart.java)

我正在使用Edittext TextInputLayout部分代码为android xml

 <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
            >

            <EditText
                android:id="@+id/et1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:hint="Notes"
                android:textSize="@dimen/edit_text_size"/>
        </android.support.design.widget.TextInputLayout>

dimens.xml

<dimen name="edit_text_size">22sp</dimen>

第38行:我在布局中定义了第一个Editext,存在膨胀问题:

enter image description here

res/value/stylesres/value-sw720dp我已经为提示文字定义了样式:

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

我无法找到这次崩溃的原因!请帮忙

2 个答案:

答案 0 :(得分:1)

我在你的logcat上看到了这个错误

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1

尝试将android:textSize="@dimen/edit_text_size"/>更改为任何值

答案 1 :(得分:0)

尝试清理项目并重建它,注意是否有额外的Invaild char