I am getting the exception:
Fatal Exception: android.content.res.Resources$NotFoundException: Drawable org.radarcns.detail:drawable/status_searching with resource ID #0x7f080130
Caused by android.content.res.Resources$NotFoundException: Resource "org.radarcns.detail:drawable/status_searching" (7f080130) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f080130 a=11 r=0x7f080130}
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:828)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:673)
at android.content.res.Resources.loadDrawable(Resources.java:1002)
at android.content.res.Resources.getDrawableForDensity(Resources.java:992)
at android.content.res.Resources.getDrawable(Resources.java:931)
at android.content.Context.getDrawable(Context.java:810)
at androidx.core.content.ContextCompat$Api21Impl.getDrawable(ContextCompat.java:1049)
at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:485)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:149)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:137)
at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:66)
at androidx.appcompat.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:91)
at androidx.appcompat.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:102)
at org.radarcns.detail.SourceRowView$updateSourceStatus$1.invoke(SourceRowView.kt:155)
at org.radarcns.detail.SourceRowView$updateSourceStatus$1.invoke(SourceRowView.kt:152)
at org.radarbase.android.util.ChangeApplier.applyIfChanged(ChangeApplier.kt:72)
at org.radarcns.detail.SourceRowView.updateSourceStatus(SourceRowView.kt:152)
at org.radarcns.detail.SourceRowView.display(SourceRowView.kt:148)
at org.radarcns.detail.MainActivityViewImpl.update$lambda$6(MainActivityViewImpl.kt:157)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7918)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
The code in SourceRowView where I am getting this error is as follows:
private val mStatusIcon: ImageView = findViewById(R.id.status_icon)
mStatusIcon.setImageResource(R.drawable.status_searching)
Where R.drawable.status_searching is present in src/main/res/drawable which contains:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/ic_searching" />
</layer-list>
Now @drawable/ic_searching.png is in png format present in drawable-hdpi, drawable-mdpi, drawable-xhdpi and drawable-xxhdpi.
Even all the resources are present it is giving ResourceNotFound, I am not understanding why it is happening?
The problem you have here is in the logcat:
NotFoundException: Resource "org.radarcns.detail:drawable/status_searching" is not a Drawable (color or path)
As your app can't find that image in the drawable folder. This can be in case you have the image in @drawable-hdpi, @drawable-mdpi folders but your app running with @drawable-xhdpi screen density.
To be sure you have fallback @drawable/ic_searching.png file for missing density, you need to have file in @drawable too.
You can find similar issue explained here: https://stackoverflow.com/a/34707995/4977439