chrisjenx / Calligraphy

Custom fonts in Android the easy way...
Apache License 2.0
8.59k stars 1.09k forks source link

android.view.InflateException: Binary XML file line #0: Error inflating class android.widget.EditText #417

Open iad24 opened 7 years ago

iad24 commented 7 years ago

It happens to ZenFone 2 device, Android 5.0 Im using this lib version 2.3.0

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.yyy/com.myapp.modules.login.views.LoginActivity}: android.view.InflateException: Binary XML file line #0: 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 #0: Error inflating class android.widget.EditText at android.view.LayoutInflater.createView(LayoutInflater.java:633) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:164) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:148) 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 uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.view.LayoutInflater.inflate(LayoutInflater.java:365)

Full stack trace is here: stacktrace.txt

Layout xml file of Login activity: activity_login.txt

cotfas commented 6 years ago

I`m having the same issue..

iad24 commented 6 years ago

It seems this library does not work well with TextInputLayout

<android.support.design.widget.TextInputLayout
        android:id="@+id/usernameLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:theme="@style/TextAppearance.TextInputLayout.Login"
        android:layout_marginBottom="@dimen/default_margin_3"
        android:layout_marginStart="@dimen/default_margin_3"
        android:layout_marginEnd="@dimen/default_margin_3"
        android:gravity="bottom"

        >

        <EditText
            android:id="@+id/usernameEditTxt"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="@dimen/default_margin_3"
            android:textSize="16sp"
            android:singleLine="true"
            android:textColor="@color/colorGrey3"
            android:hint="Username"
            android:text="dindun.test02+5003@gmail.com"
            android:inputType="textEmailAddress"
            />
    </android.support.design.widget.TextInputLayout>

style.xml

<style name="TextAppearance.TextInputLayout.Login">
        <item name="fontPath">fonts/font.ttf</item>
        <item name="android:textColorHint">@color/colorAccent2</item>
        <item name="colorAccent">@color/colorGrey4</item>
        <item name="colorControlNormal">@color/colorGrey6</item>
        <item name="colorControlActivated">@color/colorAccent2</item>
        <item name="android:textSize">16sp</item>
    </style>

If I remove the android:theme in TextInputLayout, the exception is gone.

xPryds commented 6 years ago

Same issue but with Buttons.

android.view.InflateException: Binary XML file line #0: Error inflating class Button

Device: LG G3 Operating System: 4.4.2

`

Caused by android.content.res.Resources$NotFoundException

  | android.content.res.Resources.loadDrawable (Resources.java:2136)   | android.support.v7.app.AppCompatDelegateImplV9.onCreateView (Unknown Source)   | uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory2.onCreateView (Unknown Source)   | android.view.LayoutInflater$FactoryMerger.onCreateView (LayoutInflater.java:172)   | android.view.LayoutInflater.inflate (LayoutInflater.java:492)   | uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate (Unknown Source)   | android.view.LayoutInflater.inflate (LayoutInflater.java:397)   | com.buildone.delivery.features.profile.DriverProfileFragment.onCreateView (Unknown Source)   | android.support.v4.app.Fragment.performCreateView (Unknown Source)   | dalvik.system.NativeStart.main (NativeStart.java)

Caused by org.xmlpull.v1.XmlPullParserException

  | android.graphics.drawable.Drawable.createFromXmlInner (Drawable.java:933)   | android.support.v7.app.AppCompatDelegateImplV9.onCreateView (Unknown Source)   | uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory2.onCreateView (Unknown Source)   | android.view.LayoutInflater$FactoryMerger.onCreateView (LayoutInflater.java:172)   | android.view.LayoutInflater.inflate (LayoutInflater.java:492)   | uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate (Unknown Source)   | android.view.LayoutInflater.inflate (LayoutInflater.java:397)   | com.buildone.delivery.features.profile.DriverProfileFragment.onCreateView (Unknown Source)   | android.support.v4.app.Fragment.performCreateView (Unknown Source)   | dalvik.system.NativeStart.main (NativeStart.java)

EDIT: My problem was using vector drawables in android buttons. Not related to calligraphy.

swat-cat commented 6 years ago

Same issue with LG H810 Android 5.1

enriqkeg commented 6 years ago

Same problem with LG k240h 6.0

CaviaTheGuineaPig commented 6 years ago

I had the same bug, and cause by the attribute "BackgroundTint" in the Floating button view

Tizhoodh82 commented 6 years ago

I have same issue in SAMSUNG GLAXAY J5 .

uliluck commented 6 years ago

same issue in android studio 3.0 OS 4.4.2

Sufi313 commented 6 years ago

/AndroidRuntime: FATAL EXCEPTION: main Process: com.taggroup.www.darzeeco, PID: 3664 android.view.InflateException: Binary XML file line #0: Error inflating class ImageButton at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:714) at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) at android.view.LayoutInflater.rInflate(LayoutInflater.java:759) 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 com.taggroup.www.darzeeco.CustomerAct.CartAdapter.onCreateViewHolder(CartAdapter.java:42) at com.taggroup.www.darzeeco.CustomerAct.CartAdapter.onCreateViewHolder(CartAdapter.java:27) at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6519) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5706) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1558) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3135) at android.view.View.measure(View.java:16497) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455) at android.view.View.measure(View.java:16497) at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1226) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.widget.ScrollView.onMeasure(ScrollView.java:326) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291) at android.view.View.measure(View.java:16497) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000) at android

Sufi313 commented 6 years ago

Hi! guys i have this error when i run application in kitkat i know multidex and i enabled but error show

sshahidaslamm commented 6 years ago

For Android Studio 3.0.1

I have got the same issue and I have resolved finally Opening the gradle.properties and added following line:

android.enableAapt2=false

techview51 commented 6 years ago

Same issue: Solved. My image files were in the "drawable-v24" folder. I copied them to the "drawable" folder too. Problem solved.

ariel179 commented 6 years ago

@techview51 you saved my life thank you!!!!

RofaeilAshaiaa commented 6 years ago

@sshahidaslamm your solution solved my problem!

techview51 commented 6 years ago

@ariel179 You are welcome.

AdrianoJunior commented 6 years ago

Same problem here but with Fragment.

ghost commented 6 years ago

@techview51 Copied and fixed, thank you so much!

samk17cmutpm commented 6 years ago

@techview51 Thank you so much !

ghost commented 6 years ago

@techview51 thanks a ton mate 🗡

techview51 commented 6 years ago

@TBaulos , @samk17cmutpm , @UnselfconsciousLux : You are welcome.

georgetsiga commented 6 years ago

Also had the same ussue, I did what @techview51 said and it worked.

allexiusw commented 6 years ago

@techview51 thanks for solutions... very simple!

CowardlyVillain commented 6 years ago

me: FATAL EXCEPTION: main Process: com.example.ennie.miniproject, PID: 15398 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ennie.miniproject/com.example.ennie.miniproject.LoginActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2572) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5728) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class Button at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:286) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.ennie.miniproject.LoginActivity.onCreate(LoginActivity.java:26) at android.app.Activity.performCreate(Activity.java:6371) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)  at android.os.Handler.dispatchMessage(Handler.java:111)  at android.os.Looper.loop(Looper.java:207)  at android.app.ActivityThread.main(ActivityThread.java:5728)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)  Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class Button at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:286)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.example.ennie.miniproject.LoginActivity.onCreate(LoginActivity.java:26)  at android.app.Activity.performCreate(Activity.java:6371)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)  at android.os.Handler.dispatchMessage(Handler.java:111)  at android.os.Looper.loop(Looper.java:207)  at android.app.ActivityThread.main(ActivityThread.java:5728)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)  Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.ennie.miniproject:drawable/shape" (7f070077) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f070077 a=-1 r=0x7f070077} at android.content.res.Resources.loadDrawableForCookie(Resources.java:2899) at android.content.res.Resources.loadDrawable(Resources.java:2821) at android.content.res.TypedArray.getDrawable(TypedArray.java:870) at android.view.View.(View.java:4001) at android.widget.TextView.(TextView.java:700) at android.widget.Button.(Button.java:109) at android.widget.Button.(Button.java:105) at android.support.v7.widget.AppCompatButton.(AppCompatButton.java:65) at android.support.v7.widget.AppCompatButton.(AppCompatButton.java:61) at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:109) at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1023) at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1080) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:286)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.example.ennie.miniproject.LoginActivity.onCreate(LoginActivity.java:26)  at android.app.Activity.performCreate(Activity.java:6371)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)  at android.os.Handler.dispatchMessage(Handler.java:111)  at android.os.Looper.loop(Looper.java:207)  at android.app.ActivityThread.main(ActivityThread.java:5728)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 

anshkumarsaha commented 6 years ago

you need to change AppTheme @styles.xml like its really work

If you really need theme color (i.e. ?attr/xxx), probably instead of regular color resource, you may need to define another color attribute in your theme.

Chandrakala14 commented 5 years ago

I am facing the issue in textInputLayout Password field

Resource not found exception Drawable drawable/design_password_eye with resource ID #0x7f080098

Please help me to solve this .

this is my build.gradle

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:support-core-ui:28.0.0'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
        }
Moonlighter commented 5 years ago

hi, all I have the same issue when i use (Android 6): On EditText:

And on RelativeLayout :

Thank's @techview51

techview51 commented 5 years ago

@techview51 Wasted 4 hours trying to solve the problem. The simple copy of image to drawable folder solved. But why does this work?

I don't know exactly, just works ;)

techview51 commented 5 years ago

@techview51 Thanks.

You are welcome.

techview51 commented 5 years ago

@techview51 Are u a hero, sir ? , you just save my life !!!

Glad to hear that. Good luck.

techview51 commented 5 years ago

Same issue: Solved. My image files were in the "drawable-v24" folder. I copied them to the "drawable" folder too. Problem solved.

You saved my life 👍

@JayTailor45 Glad to hear that. Good luck.

techview51 commented 5 years ago

hi, all I have the same issue when i use (Android 6): On EditText:

  • android:drawableStart
  • android:background

And on RelativeLayout :

  • android:background ... And when i copy resources from drawable-v24 to drawable it's work fine .

Thank's @techview51

You are welcome.

JwalaApporio commented 5 years ago

Caused by: android.view.InflateException: Binary XML file line #54: Binary XML file line #54: Error inflating class EditText

I was also getting the similar error, In my case I had added xml file's( icon) with drwable. By adding Normal png images solved the issue.

Adding xml files with drawable causes error many times, sometimes error does not come.

naveedahmad99 commented 5 years ago

copied

In my case, no drawable 24 folder exist, nor values and layout.

Duna commented 4 years ago

in my case I do not have drawable-24 or 21 in the project

AhmedMahmoudRizk commented 4 years ago

Same issue: Solved. My image files were in the "drawable-v24" folder. I copied them to the "drawable" folder too. Problem solved.

Thank you sir, it works fine you save my time