Android 12 Splash Screen Icon Not Displaying
Asked Answered
M

15

75

I am seeing a weird issue with a new app that I am starting. I am utilizing the new Android 12 splash screen API to create my splash screen and I followed the guide provided by Google to do so. I included core-splashscreen in my project to provide compatibility with older versions of Android OS. When I run the app, I see the splash screen as expected on older OS versions like API 30, but when I run it on API 31, the splash screen icon that I provide is not displayed. The background color that I specify is displayed, but the icon is not there at all. I have tried this with a drawable asset as well as a mipmap and nothing is working. I am stumped as every tutorial I find shows the same steps I have followed and screenshots of their working splash screens, but I am not having any luck.

For context here is my splash screen style definition for v31:

<style name="Theme.Splash" parent="Theme.SplashScreen">
    <item name="android:windowSplashScreenBackground">@color/orange_7A</item>
    <item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_foreground</item>
    <item name="postSplashScreenTheme">@style/Theme.App</item>
</style>

I have an identical style for all other OS versions except I'm using "windowSplashScreenAnimatedIcon" instead of "android:windowSplashScreenAnimatedIcon". I have tried v31 with and without the "android:" in front of the item names and neither work. Here is my MainActivity.kt:

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    installSplashScreen()
    
    setContent {
        MyVeevaTheme {
            Login()
        }
    }
}

I am also setting the "android:theme" property to my splash style in my AndroidManifest.xml. I know the splash style is being applied because it honors the background color, but it is not showing the icon for some reason even though the icon shows fine for older OS versions. Thanks in advance for any help you can give.

Mikamikado answered 2/11, 2021 at 15:5 Comment(8)
Same, just tried out the new splash screen API on an Android 12 emulator, but too bad the icon is not showing, whether I set the "android:windowSplashScreenAnimatedIcon" or not, but the "android:windowSplashScreenBackground" is working though. Should we consider it as a bug? The API is not very friendly for older version of Android devices I think.Keystone
Yeah, I think I'll try logging a bug to google and see what they say.Mikamikado
Well, I did figure out how to get it to show. I was following this tutorial to set up a base project to recreate the issue and I noticed the note the author put right near the bottom that mentions that just running the app doesn't show the splash screen. You have to kill it and open the app from the app tray. Once I did that, I was able to see my splash screen. Annoying, but at least I have a way to test it now.Mikamikado
I went ahead and logged the bug report since this is confusing, but with my last comment, I have a way to test this now. Here's the bug report if anyone is curious: issuetracker.google.com/issues/205021357.Mikamikado
Having the same issue, doesnt seem like google have gotten around to investigating it yet. Hopefully soon.Nitriding
You should remove the android prefix if using the libraryBarbitone
If running from Android Studio, the splash screen does not show properly, but if you launch the installed app from the launcher on the device you might see it works properly. That's how it was for my Google Pixel 4a which runs Android 12.Telford
Still like that now a year later!Dm
M
138

TL;DR kill the app and run from the launcher, icon does not show up when run from Android Studio.

Adding my comment here as an answer for better visibility.

I did figure out how to get it to show. I was following this tutorial to set up a base project to recreate the issue and I noticed the note the author put right near the bottom that mentions that just running the app doesn't show the full splash screen. You have to kill it and open the app from the launcher. Once I did that, I was able to see my splash screen. Annoying, but at least I have a way to test it now. I did go ahead and log a bug report for this as well, but I have a work around for now. Thanks for everyone's answers/comments!

Mikamikado answered 3/11, 2021 at 20:5 Comment(11)
This issue was driving me insane. I followed Googles Guide on how to migrate and the other docs regarding the SplashScreen API. But on my Pixel I use Nova Launcher as desktop and you will never get the icon/images on the splash screen when launching the app from a shortcut or the drawer when using Nova Launcher. And still the same when launching with Android Studio. I only got the icon/images on the splash screen when I launched the app with the Pixel Launcher. So poorly done.Marlyn
What does it mean to run an app from tray? Do you mean I must user the launcher on the phone? I think this needs rephrasing.Telford
Geez, Android. Always good for a surprise. Looks like it is still buggy (well the lib is beta, so no surprise - however it is already enforced for api level 31) Thanks Joseph for the workaround, this already saved me a lot of time! However I can't access the bug report, is the link correct? And the issue with the other launcher as mentioned by @Marlyn is very annoying too.Shearer
@AndrewS, yeah, I’m new to Android so still getting the right terminology down. Switched it to be launcher instead of app tray for clarity.Mikamikado
@Luzian, I got email updates for that bug report up until Jan 25th. I’m also getting access denied when I visit it now though so not sure what’s up there.Mikamikado
I found another report logged by someone else and it seems like Google is marking this as intended behavior… link for reference: issuetracker.google.com/199776339Mikamikado
classic Googlers. It is driving me nuts, that things rarely works as described in docs...How they always find a way to screw something up, not make it properly, or buggy?Cuneo
Half-baked API as alwaysKaryolymph
This issue produced a lot of F's followed by a lot of U's in the last 40 minutes.Alaniz
absolutely right answer for me, i wasted 3Hr for this stupid issue of androidSatiety
Wasted a day on this thinking the app wasn't showing the splash icon... then I went down a rabbit and saw this. So stupid that it works on phone launcher but not from IDE launch! ughDm
L
12

folks as per the document installSplashScreen() should have been called prior to super.onCreate()

Lally answered 16/2, 2022 at 18:3 Comment(3)
This is a good catch. It would be nice if that documentation was directly on the installSplashScreen function instead of on SplashScreen class level or in this guide: developer.android.com/guide/topics/ui/splash-screen. I have no reason to reference the SplashScreen class directly unless I'm doing more sophisticated customization. Unfortunately, moving the installSplashScreen call to the right place still doesn't fix this issue.Mikamikado
Looking at the code, it seems like they recommend calling installSplashScreen before super.onCreate() because setContentView is called internally in super.onCreate() and the installSplashScreen doc does specify that it needs to be called before setContentView. It looks like that only applies if you are initializing your activity with a view ID instead of manually inflating the view. Since I'm using Compose I think as long as it's called before my setContent block, it's fine. Definitely doesn't hurt to move it before super.onCreate though.Mikamikado
no difference in my caseKamacite
B
10

When you use the AndroidX SplashScreen Library, like you are doing (Theme.SplashScreen) you need to use the windowSplashScreen* attributes without the android: prefix.

The android: prefix is used to call the platform attributes, but in this case you are using the library and not the platform, so no need for the prefix:

res/values/themes.xml:

<style name="Theme.Splash" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">@color/orange_7A</item>
    <item name="windowSplashScreenAnimatedIcon">@drawable/splash_foreground</item>
    <item name="postSplashScreenTheme">@style/Theme.App</item>
</style>
Barbitone answered 3/11, 2021 at 14:31 Comment(4)
That is correct, but still, be aware of others said: the library is in alpha, so it's a little bit unstable. In most cases it works as expected, however, I've noticed that when I adb install the app that is already open, when I open it, the icon does not show. Also, I could not get the icon to work for API below 23. It works fine from API 23 and above. From the release notes, I guess that was expected: developer.android.com/jetpack/androidx/releases/…Cassette
Ok, that makes sense. I have tried it both with and without the "android:" prefix and it doesn't work on API 31 either way, though. It works fine on API 30, though. I'm a little surprised that it would be this sort of issue since the feature is new and designed for API 31 so that's the last place I expected to run into issues.Mikamikado
Vadim, please elaborate on exactly where we will use this. Name the resource file, manifest or other where this needs to go. As written this is very unclear.Telford
This was in context of OP answer. I'll add some details to my answerBarbitone
E
10

In my case, the problem with the lack of a splash screen was the installation of the default activity theme:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:name=".App"
        android:theme="@style/Theme.Tracker.StartSplashScreen"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        tools:targetApi="tiramisu">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:theme="@style/Theme.Tracker">                 <-------
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

When I deleted android:theme="@style/Theme.Tracker" line, it started working.

Evelinevelina answered 14/2, 2023 at 11:59 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Deledda
Same issue was appearing on api<31. Your solution worked for me.Maggio
R
6

For some reason when the app is launched through android studio it doesn't show the icon. Kill the app and launch app from the menu. Then the icon will appear. This is true if you are not using Splash API: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate

Ruthieruthless answered 31/8, 2022 at 8:28 Comment(1)
This answer has already been provided by the OPSwane
C
4

Icons are also not shown when navigating from the deeplink. And It looks like its more then only not showing the icon. It also stops calling code for setOnExitAnimation lambda.

installSplashScreen().apply {
    setOnAnimationListener { viewProvider ->
    viewProvider.iconView
    .animate()
    .setDuration(500L)
    .alpha(0f)
    .withEndAnimation {
       viewProvider.remove()
       someActionCall() 
    }
    .start()
} 

If you relied upon this code to be always called it is not. See mention in issue tracker: https://issuetracker.google.com/issues/207095799

Choreography answered 7/12, 2021 at 16:25 Comment(0)
M
4

Make sure you set the theme to the MainActivity as well. For me that was the cause for the splash screen to now show. So you have to set the theme in both the application and the MainActivity

Mend answered 14/7, 2022 at 17:30 Comment(0)
W
3

The following instructions helped me, you may try this one. A few things need to keep in mind while working with the new splash screen API.

  1. Keep updated on the latest library version. Follow this link (https://developer.android.com/jetpack/androidx/releases/core).
  2. Put installSplashScreen() before setContentView()
  3. Make a proper theme for the splash screen. You may try the following one.

Put this into your styles.xml or themes.xml folder and use it with your activity as the theme.

 <!-- Splash Screen Theme. -->
<style name="Theme.AppSplash" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">@color/white</item>
    <item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher_round</item>
    <item name="windowSplashScreenAnimationDuration">1000</item>
    <item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
Wiper answered 19/5, 2022 at 8:19 Comment(0)
M
3

Just in case for who faces the issue of the SplashScreen API not always displaying the icon in API 33 and higher, add this to your styles.xml:

<item name="android:windowSplashScreenBehavior"tools:targetApi="33">icon_preferred</item>

Reference from Android Docs:

You can use windowSplashScreenBehavior to specify whether your app always displays the icon on the splash screen in Android 13 and higher. The default value is 0, which displays the icon on the splash screen if the launching activity sets the splashScreenStyle to SPLASH_SCREEN_STYLE_ICON, or follows the system behavior if the launching activity doesn't specify a style. If you prefer to never display an empty splash screen and always want the animated icon to be displayed, set this to the value icon_preferred.

It is intended to hide the icon when starting the app from a notification or from another app other than the Launcher. So just use the above styles attribute to force it to always show the icon.

In case you have a separate file for API 31 and above, values-v31/styles.xml, omit the `tools' attribute.

<item name="android:windowSplashScreenBehavior">icon_preferred</item>
Macur answered 17/10, 2023 at 10:46 Comment(1)
This is the one that did it for me. Was having this issue when trying to load an activity from a deeplink where I still want to see the splash screen & icon. Thanks!Vagal
B
3

From my side I wrote the theme in the Application and Activity tags in the manifest file so keep only one theme in the Application tag only

 <application
    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"
    android:theme="@style/Theme.MySplash"
    tools:targetApi="31">
Biggerstaff answered 13/12, 2023 at 17:30 Comment(0)
B
2

In addition to the other explanations above, I had the same issue but I realized that in my Manifest file I was setting the Splashscreen theme on my MainActivity which is correct, but my MainActivity was not having the main/launcher intent-filter which tells the android OS that this is the starting activity.

<intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

So in your manifest, check that you are actually setting the Splashscreen theme on the Starting activity that is having the main/launcher intent-filter, and leave the Application tag to have your application theme and not the Splashscreen theme, to avoid having your app misbehave on other activities due to the theme because I experienced that too (This is especially for those migrating to the new splash screen).

Thank you, I hope someone finds this helpful

Bullyrag answered 22/9, 2022 at 14:32 Comment(0)
S
1

To @Gimberg above who said the icon doesn't display with Nova Launcher, thank you, I've spent a day trying to figure out why this wasn't working when it had been.

Sennacherib answered 22/6, 2023 at 8:55 Comment(1)
Wow that was the reason for me too, would have never thought of that, thanks for saving my day.Prism
A
1

On Samsung Galaxy M31 (Android 12, One Ui Core version 4.1) the icon isn't displayed when launch from the Launcher. But it is shown when launch from Home screen.

Animato answered 7/9, 2023 at 20:33 Comment(0)
C
0

I had the same problem on my phone running Android 12. None of the above suggestions worked, (moving installSpashScreen() above super.onCreate etc...)

What fixed it for me was adding the android:theme attribute in the manifest to the Launching <activity> Tag, Not the <application> Tag, which is contrary to the documentation :

In the manifest, replace the theme of the starting activity to the theme you created in the previous step.

<manifest>
 <application android:theme="@style/Theme.App.Starting">
 <!-- or -->
     <activity android:theme="@style/Theme.App.Starting">

Note, you still have to kill the activity and launch it from the launcher for this to work :(

Costume answered 28/1, 2023 at 9:7 Comment(0)
B
0

If you are not seeing the splash icon in versions before android 12 (where AVD is not supported):

Ensure you are using a valid icon and that you do not define android:windowBackground in your SplashTheme. windowBackground will paint above the icon making it invisible.

Bathe answered 1/7, 2024 at 13:11 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.