Monday 24 August 2020

ResourcesNotFoundException at NinePatchDrawable

I am getting ResourcesNotFoundException when trying to get nine patch drawable at below line .Devices I am having this issue are LGE Nexus(Android 8) and Google Pixel(Android 10).Other devices on which I have tried it's working fine.

mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
                (NinePatchDrawable) ContextCompat.getDrawable(this, R.drawable.material_shadow_z3));

Exception

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo: android.content.res.Resources$NotFoundException: Resource ID #0x7f0800af
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
       at android.app.ActivityThread.-wrap11(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6541)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
Caused by android.content.res.Resources$NotFoundException: Resource ID
#0x7f0800af
       at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:204)
       at android.content.res.Resources.getDrawableForDensity(Resources.java:875)
       at android.content.res.Resources.getDrawable(Resources.java:818)
       at android.content.Context.getDrawable(Context.java:605)
       at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:463)
       at init(ImagesActivity.java:211)
       at onCreate(ImagesActivity.java:121)
       at android.app.Activity.performCreate(Activity.java:6975)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
       at android.app.ActivityThread.-wrap11(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6541)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

I have provided material_shadow_z3 in drawable-hdpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi,drawable-xxhdpi.Like-

material_shadow_z3.xml

<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:src="@drawable/material_shadow_z3_mdpi"
    tools:ignore="unused" />


from ResourcesNotFoundException at NinePatchDrawable

No comments:

Post a Comment