1

Hi all my application is working fine but I am getting a crash coming in Android Tablet with version 4.4.2 but don't know why as application is working fine in other versions perfectly. Error i am getting :

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{}: android.view.InflateException: Binary XML file line #38: Error inflating class EditText android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(NativeStart.java) Caused by android.view.InflateException: Binary XML file line #38: Error inflating class EditText at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(NativeStart.java) Caused by java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1 at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:464) at android.widget.TextView.(TextView.java:972) at android.widget.EditText.(EditText.java:60) at android.support.v7.widget.AppCompatEditText.(AppCompatEditText.java:60) at android.support.v7.widget.AppCompatEditText.(AppCompatEditText.java:56) at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:112) at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:1008) at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1067) at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(NativeStart.java)

I am using Edittext with TextInputLayout some code of 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>

line #38: where i have defined first Editext in my layout there is inflating issue :

enter image description here

In res/value/styles and res/value-sw720dp i have defined style for hint text :

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

I can't find why this crash is coming! please help

Kapil Rajput
  • 11,429
  • 9
  • 50
  • 65
  • Which line is you line #38 from the given snippet? – vidulaJ Oct 20 '16 at 07:06
  • Are you sure you have the `edit_text_size` dimension defined in every `res/values*/` folder? Particularly in `res/values/`. – Mike M. Oct 20 '16 at 07:06
  • can you post your build.gradle file – AbhayBohra Oct 20 '16 at 07:07
  • @vidulaJ in java code line#38 is `setContentView` in `onCreate` – Kapil Rajput Oct 20 '16 at 07:11
  • That line refers to a line in the xml file. I am asking of which line on the given snippet. There are 14 lines in the given xml and which line it is? – vidulaJ Oct 20 '16 at 07:13
  • @MikeM. yes i have defined `edit_text_size` in `dimens` – Kapil Rajput Oct 20 '16 at 07:13
  • Right, but in which folder? There can be multiple `res/values*/` folders. You need to make sure to have a value for that in the `dimens.xml` in specifically `res/values/`. – Mike M. Oct 20 '16 at 07:20
  • @vidulaJ please check screenshot i have added in my question – Kapil Rajput Oct 20 '16 at 07:23
  • please post the hint style that you defined in: `TextAppearance.App.TextInputLayout` – hakim Oct 20 '16 at 07:25
  • @MikeM. yes i have did defined edittext dimension in both folders res/values/ and res/values-sw720dp/ – Kapil Rajput Oct 20 '16 at 07:27
  • @hakim i have edited my question please check – Kapil Rajput Oct 20 '16 at 07:31
  • thank you, that part of style is not help much, since it child style of `TextAppearance.App`, please try remove style attribute ` app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"` in TextInputLayout is it work? – hakim Oct 20 '16 at 07:33
  • Have you tried "TextAppearanceAppTextInputLayout" (removed '.') for style name? Error log line number sometimes show different line which causes error. (Error may happen before EditText line.) – Toris Oct 20 '16 at 07:41
  • @Kapil Rajput have you defined com.android.support:design:* in build.gradle file? – vidulaJ Oct 20 '16 at 08:18
  • @vidulaJ yes i have defined it, in all version rather that android 4.4 app is running fine – Kapil Rajput Oct 20 '16 at 08:29
  • See the accepted answer in this link. http://stackoverflow.com/questions/36385055/error-inflating-class-edittext-on-creating-textinputlayout-on-android-4-4-2 – vidulaJ Oct 20 '16 at 08:31

2 Answers2

1

I saw this error on your logcat

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

Try changing android:textSize="@dimen/edit_text_size"/> into any value

Fay Zan
  • 165
  • 2
  • 17
0

try to clean your project and rebuild it, notice whether have extra Invaild char around

yan
  • 41
  • 4