You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启动SplashActivity时Resources$NotFoundException崩溃求助

排查并解决SplashActivity资源找不到崩溃问题

崩溃日志

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)

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

关联代码

SplashTheme样式

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

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>

项目build.gradle配置

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'
}

排查分析

从崩溃子错误可定位到:资源ID#0x7f07015e对应splash_icon,即便该图标覆盖全分辨率目录,仍可能存在以下问题:

  • 部分分辨率下的splash_icon.png文件损坏,无法被系统解析
  • 资源文件名大小写不一致(部分Android系统/文件系统对大小写敏感)
  • layer-list直接引用drawable的方式在minSdk19版本存在兼容缺陷
  • 构建缓存残留异常资源,导致打包时未正确纳入图标
  • 资源合并过程中出现冲突,导致splash_icon被意外排除

解决方案

  • 校验图标完整性:逐个检查drawable-ldpi至drawable-xxxhdpi目录下的splash_icon.png,确保文件可正常打开、尺寸符合对应分辨率规范,无损坏或截断。
  • 统一命名格式:确保所有目录下的图标文件名均为小写splash_icon.png,规避大小写敏感导致的资源查找失败。
  • 优化layer-list引用:将直接引用drawable的item改为包裹bitmap标签,提升低版本系统兼容性:
    <item android:gravity="center">
        <bitmap android:src="@drawable/splash_icon" />
    </item>
    
  • 清理缓存重建:执行Build -> Clean Project,再执行Build -> Rebuild Project,彻底清除旧缓存中的异常资源。
  • 临时关闭资源压缩:在android块中添加以下配置,排查是否是AAPT压缩损坏了png文件:
    aaptOptions {
        cruncherEnabled = false
    }
    
  • 检查资源合并日志:查看Android Studio的Build窗口输出,搜索splash_icon相关警告或错误,确认是否存在资源冲突或合并失败情况。

内容的提问来源于stack exchange,提问作者Sanjay S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 22:15:55