1
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{com.packageName/com.packageName.SplashActivity}: 
android.content.res.Resources$NotFoundException: Drawable 
com.packageName:drawable/splash_background with resource ID #0x7f07015d
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3900)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:4057)
android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:103)
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:2407)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loopOnce (Looper.java:233)
android.os.Looper.loop (Looper.java:334)
android.app.ActivityThread.main (ActivityThread.java:8278)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:582)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1065)

Firebase Crashlytics show error like this

Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{com.packageName/com.packageName.SplashActivity}: android.content.res.Resources$NotFoundException: Drawable com.packageName:drawable/splash_background with resource ID #0x7f07015d

and, next is

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

I've custom SplashActivity with just background and drawable in center on it. Using SplashTheme style like this

<style name="SplashTheme" parent="@style/Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/splash_background</item> <!-- Resource ID #0x7f07015d -->
</style>

Here is my splash_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
    <item android:drawable="@drawable/gradient_splash" /> <!-- Resource ID #0x7f0700af -->
    
    <item android:drawable="@drawable/splash_icon" android:gravity="center" /> <!-- Resource ID #0x7f07015e -->
</layer-list>

Here is my build.gradle configuration

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android {
compileSdkVersion 33
defaultConfig {
    multiDexEnabled true
    applicationId "com.packageName"
    minSdkVersion 19
    targetSdkVersion 33
    versionCode "VERSION_CODE"
    versionName "VERSION_NAME"
    vectorDrawables.useSupportLibrary = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
}
namespace 'com.packageName'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.core:core:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.browser:browser:1.4.0'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.media:media:1.6.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.work:work-runtime:2.7.1'

implementation 'com.google.android.play:core:1.10.3'

implementation 'com.google.firebase:firebase-core:21.1.1'
implementation 'com.google.firebase:firebase-analytics:21.2.0'
implementation 'com.google.firebase:firebase-messaging:23.1.0'
implementation 'com.google.firebase:firebase-config:21.2.0'
implementation 'com.google.firebase:firebase-ads:21.3.0'
implementation 'com.google.firebase:firebase-crashlytics:18.3.1'

implementation 'com.android.volley:volley:1.2.1'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.facebook.shimmer:shimmer:0.4.0'
implementation 'com.synnapps:carouselview:0.1.5'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'saschpe.android:customtabs:2.0.3'
implementation 'com.mikhaellopez:circularfillableloaders:1.3.2'
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.0.3'
}

For your information splash_background.xml is available in drawable folder, gradient_splash.xml is available in drawable folder and splash_icon.png is available in drawable-ldpi, drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi, drawable-xxxhdpi folders.

Sanjay S
  • 112
  • 13
  • You shall place the .png file in the Resources/drawable folder as a fallback plan. – Android Newbie A Nov 08 '22 at 10:53
  • I believe the splash_icon.png is not found since the device does not recognise what DPI it is using or somehow it is a "new" DPI. So it will try to lookup the drawable folder (default) for the resource. – Android Newbie A Nov 08 '22 at 10:54
  • I tried to put splash_icon.png in drawable, drawable-nodpi, drawable-anydpi but still error persist. so I removed from these folders. – Sanjay S Nov 08 '22 at 15:04

1 Answers1

0

In My Opinion, You Need to Use Difference sizes of image drawable like (drawable-hdpi,drawable-mdpi,drawable-xhdpi, drawable-xxhdpi , etc..)

also you can use Android Drawable Important to import Drawable with difference size.

may be found an issue with importing this library in the latest version of an android studio so you can see this solve and use it.

Hatem Darwish
  • 33
  • 1
  • 5
  • Hi @Hatem, I'm using different size of images as I mentioned in my question, drawable-mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi but still this exception persist. – Sanjay S Nov 08 '22 at 15:02
  • Hello @SanjayS Maybe you are missing one of these type needs for your testing device or emulator drawable-hdpi drawable-mdpi drawable-v24 drawable-xhdpi drawable-xxhdpi drawable-xxxhdpi drawable – Hatem Darwish Nov 08 '22 at 18:46