1

I know there are a bunch of similar questions on stackoverflow but none of them seem to solve my problem.

The problems previously mentioned always have some place where the drawable is missing. Which is not the case with this project.

The line number being pointed in error log leads me to this textView which has a 9-patch image as a background

The Layout

<TextView
    android:clickable="true"
    android:focusable="true"
    android:id="@+id/update_available"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_vertical|start"
    android:background="@drawable/tab_white_left_9"
    android:text="@string/update_available"
    android:textColor="@android:color/white"
    android:backgroundTint="@color/lead_color"
    app:drawableStartCompat="@drawable/ic_download"
    android:drawablePadding="@dimen/margin_5"
    android:paddingStart="@dimen/margin_5"
    style="@style/text_bold_11"
    app:drawableTint="@android:color/white"
    android:visibility="gone"/>

Drawable Locations

  • res/drawable-ldpi/tab_white_left_9.9.png
  • res/drawable-mdpi/tab_white_left_9.9.png
  • res/drawable-hdpi/tab_white_left_9.9.png
  • res/drawable-xhdpi/tab_white_left_9.9.png
  • res/drawable-xxhdpi/tab_white_left_9.9.png
  • res/drawable-xxxhdpi/tab_white_left_9.9.png

Error Logs

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{in.callific.quickinsure/in.callific.quickinsure.activity.HomeScreenActivityV2}: android.view.InflateException: Binary XML file line #16 in in.callific.quickinsure:layout/activity_home_screen_v2: Binary XML file line #580 in in.callific.quickinsure:layout/content_home_screen_activity_v2: Error inflating class TextView
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3813)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3975)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2377)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:233)
       at android.os.Looper.loop(Looper.java:344)
       at android.app.ActivityThread.main(ActivityThread.java:8204)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:589)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1071)
Caused by android.view.InflateException: Binary XML file line #16 in in.callific.quickinsure:layout/activity_home_screen_v2: Binary XML file line #580 in in.callific.quickinsure:layout/content_home_screen_activity_v2: Error inflating class TextView


Caused by android.view.InflateException: Binary XML file line #580 in in.callific.quickinsure:layout/content_home_screen_activity_v2: Error inflating class TextView


Caused by android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID #0x7f0802ba


Caused by android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f0802ba
       at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:296)
       at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:895)
       at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:735)
       at android.content.res.Resources.loadDrawable(Resources.java:1012)
       at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:1007)
       at android.content.res.TypedArray.getDrawable(TypedArray.java:982)
       at android.view.View.<init>(View.java:5559)
       at android.widget.TextView.<init>(TextView.java:1054)
       at android.widget.TextView.<init>(TextView.java:1048)
       at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:108)
       at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:103)
       at androidx.appcompat.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:201)
       at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:121)
       at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1569)
       at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1620)
       at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1071)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1001)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1144)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1105)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1147)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1105)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1147)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1105)
       at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1284)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1140)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1105)
       at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1284)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1140)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1105)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
       at in.callific.quickinsure.databinding.ActivityHomeScreenV2Binding.inflate(ActivityHomeScreenV2Binding.java:59)
       at in.callific.quickinsure.databinding.ActivityHomeScreenV2Binding.inflate(ActivityHomeScreenV2Binding.java:53)
       at in.callific.quickinsure.activity.HomeScreenActivity.onCreate(HomeScreenActivity.kt:174)
       at in.callific.quickinsure.activity.HomeScreenActivityV2.onCreate(HomeScreenActivityV2.kt:83)
       at android.app.Activity.performCreate(Activity.java:8130)
       at android.app.Activity.performCreate(Activity.java:8110)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1343)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3975)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2377)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:233)
       at android.os.Looper.loop(Looper.java:344)
       at android.app.ActivityThread.main(ActivityThread.java:8204)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:589)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1071)

When similar exceptions were raised for other drawables in this project, I switched to using vector drawables for those images, but this drawable being a 9-patch image cannot be converted to a vector image.

Edit:

Placing a low-res tab_white_left_9 in the default drawable folder /res/drawable solved this issue, still, a better solution for this problem would be appreciated as now there are duplicate drawables present for any particular resolution.

  • 1
    My guess is that the device you are testing the app on doesn't match any of the drawable folders that you have defined. Place a copy of the drawable in the default folder "res/drawable/tab_white_left_9.9.png" to see if the error goes away. – Cheticamp Dec 22 '22 at 16:18
  • Also, are you sure you have identified the right drawable for the error? – Cheticamp Dec 22 '22 at 19:21
  • I am sure that this is the drawable for this error, as the textview for which InflationException is thrown has only this as a background and no other drawable associated with it. – sushant sangle Dec 23 '22 at 10:31
  • `app:drawableStartCompat="@drawable/ic_download"` is a drawable. – Cheticamp Dec 23 '22 at 14:25
  • Yes, but it is a vector drawable that is already in the default drawable, adding tab_white_9 in default drawable folder fixed this problem. Although this is not the ideal behaviour I was going for as there are duplicate drawables now but it is working fine now. – sushant sangle Dec 28 '22 at 06:05
  • What device are you having this issue with? – Cheticamp Dec 28 '22 at 14:55

0 Answers0