Android Splash Screen API修改生效异常问题求助
闪屏修改后不生效问题
修改闪屏(Splash Screen)并重新安装应用后,闪屏未发生变化;偶尔次日首次构建能识别修改内容,但修改颜色后重装应用,闪屏仍保持不变,现象反常。
调试设备为ZTE Benefit M8(Android 7.1.2定制固件)。
相关配置
app模块res文件夹
- values/splash_theme.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="Theme.App.Starting1" parent="Theme.SplashScreen"> <item name="windowSplashScreenBackground">#069056</item> <item name="windowSplashScreenAnimationDuration">1000</item> <item name="postSplashScreenTheme">@style/Theme.NextTheme</item> </style> </resources>
- values-night/splash_theme.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="Theme.App.Starting1" parent="Theme.SplashScreen"> <item name="windowSplashScreenBackground">#ff1212</item> <item name="windowSplashScreenAnimationDuration">1000</item> <item name="postSplashScreenTheme">@style/Theme.NextTheme</item> </style> </resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <uses-permission android:name="android.permission.INTERNET" /> <application android:name="myApp.app.App" android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" tools:targetApi="31"> <activity android:name="myApp.presentation.MainActivity" android:exported="true" android:launchMode="singleTask" android:theme="@style/Theme.App.Starting1"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
build.gradle.kts
plugins { id(Dependencies.Plugins.application) id(Dependencies.Plugins.kotlin) id(Dependencies.Plugins.kapt) id(Dependencies.Plugins.serialization) id(Dependencies.Plugins.parcelize) } android { namespace = Config.Namespace.App compileSdk = Config.Sdk.compile defaultConfig { applicationId = Config.applicationId minSdk = Config.Sdk.min targetSdk = Config.Sdk.target versionCode = Config.Versions.code versionName = Config.Versions.name testInstrumentationRunner = Config.Test.instrumentationRunner } buildTypes { release { isMinifyEnabled = Config.Release.minifyEnabled // false proguardFiles( getDefaultProguardFile(Config.Release.Proguard.name), Config.Release.Proguard.rules ) } } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = Config.Kotlin.Options.jvmTarget } buildFeatures { viewBinding = true } } dependencies { implementation(project(":core")) implementation(project(":core-ui")) implementation(Dependencies.Default.core) implementation(Dependencies.Default.appCompat) implementation(Dependencies.Default.material) //Activity implementation(Dependencies.Lifecycle.activity) //Fragment implementation(Dependencies.Lifecycle.fragment) // ViewModel implementation(Dependencies.Lifecycle.viewModel) // Lifecycle implementation(Dependencies.Lifecycle.lifecycle) kapt(Dependencies.Lifecycle.lifecycleCompiler) //Splash implementation(Dependencies.splash) // androidx.core:core-splashscreen:1.0.0 ... }
MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() super.onCreate(savedInstanceState) getAppComponent().inject(this) binding = ActivityMainBinding.inflate(layoutInflater) .apply { setContentView(root) }
已尝试的解决手段
- 清除缓存
- 重启设备
- 重建项目
- 清理项目
- 通过
./gradlew重新安装依赖 - 重启Android Studio
- 卸载设备上的应用
- 重命名闪屏主题
- 重新连接USB设备
内容的提问来源于stack exchange,提问作者BoJIsHe6HuK
相关产品推荐
相关产品推荐

