Kunal Kalwar
Kunal Kalwar

Reputation: 965

android.content.res.Resources$NotFoundException: Drawable compat_splash_screen_no_icon_background with resource ID #0x7f0801b6

I am getting this issue only for samsung galaxy devices- Galaxy Tab A, Galaxy A03 Core, Galaxy A02, Galaxy A32

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.application/com.myapp.application.ui.MainActivity}: android.content.res.Resources$NotFoundException: Drawable com.app.application:drawable/compat_splash_screen_no_icon_background with resource ID #0x7f0801b6

My configuration->

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
    <style name="Theme.App.Starting" parent="Theme.SplashScreen">
        <item name="windowSplashScreenBackground">@color/white</item>

        <item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>

        <item name="postSplashScreenTheme">@style/Theme.Triva.NoActionBar</item>
        <item name="windowSplashScreenIconBackgroundColor">@color/blue</item>
        <item name="windowSplashScreenAnimationDuration">800</item>

        <item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
    </style>
</resources>

This is the resource in read only file ->

enter image description here

enter image description here

Upvotes: 1

Views: 2396

Answers (5)

Mark
Mark

Reputation: 7718

I had a similar issue and noticed the bug was only happening on low display density devices (lower than hdpi, i.e. tvdpi, mdpi and ldpi). So I managed to reproduce the crash by setting up a tvdpi emulator, and I also confirmed there was no crash on an hdpi emulator.

As a fix, I copied the drawable (webp) file from drawable-xxxhdpi to drawable-mdpi and scaled it down by a factor of 4 (512px to 128px) because xxxhdpi is 4xmdpi. See official docs.

Note: If you want to also support ldpi, you need to add a drawable in drawable-ldpi because it won't read it from any other drawable folder. You can scale down from 512px to 96px, for example.

Upvotes: 1

idunnololz
idunnololz

Reputation: 8363

This might be related to Resources$NotFoundException on Samsung

You can try disabling isShrinkResources on release builds.

Eg. In your project build.gradle.kts file

    buildTypes {
        getByName("release") {
            isShrinkResources = false
        }
    }

Upvotes: 0

RahulK
RahulK

Reputation: 184

The background must be a color value, drawables are not supported (at least for now). You can review the example in docs (https://developer.android.com/guide/topics/ui/splash-screen)

working example:

<item name="windowSplashScreenBackground">@color/colorPrimary</item>

Upvotes: 0

Ma3x
Ma3x

Reputation: 6579

This is currently an issue. You will have to wait a bit for the fix to ship, then update the core-splashscreen dependency to the latest version.

It is tracked here https://issuetracker.google.com/issues/229645249 See if the call order they suggest there helps you mitigate the problem.

Upvotes: 3

daniil krant
daniil krant

Reputation: 1

Try to rename the resource file. Looks like it interferes with some of Samsung's resource files and you have such runtime error.

Upvotes: 0

Related Questions