Resource.NotFoundException even when drawable is present in all 6 drawable folder

744 views Asked by At

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.

0

There are 0 answers