Closed paulobreim closed 1 year ago
As noted in the Android 12 section of the readme,
PLEASE NOTE: There are a number of reports that non-Google launchers do not display the launch image correctly. If the launch image does not display correctly, please try the Google launcher to confirm that this package is working.
PLEASE NOTE: The splash screen does not appear when you launch the app from a notification. Apparently this is the intended behavior on Android 12: core-splashscreen Icon not shown when cold launched from notification.
I suspect the problem is with a Samsung launcher on Andrdoid 12. Try launching in an emulator so that you are using the Google launcher. Don't launch it by running it from Android studio, but actually open the launcher in Andriod and launch by tapping the app icon. If the splash is correct, you will know that the problem is with the Samsung launcher.
Thank you for your answer.
I'll try to do more tests. There is a problem that I think you should check: When I run flutter pub run flutter_native_splash:create everything works correctly, but if I run it the first time with android12 declarations, for example: android_12: color: "#3A4F62" image: assets/images/splash.png
but if I remove the Android12 declaration, when run flutter pub run flutter_native_splash:create again, it is not eliminating the line referring to Android 12, from the files android/app/src/main/res/values-v31/styles.xml and android/app/src/main/res/values-night-v31/styles.xml and when compiling the project the error.
tks paulo
same here using android 12
DEMO:
ANDROID VERSION:
FILE SETTINGS
flutter_native_splash:
color: "#3A4F62"
image: "assets/splash.png"
android: true
ios: false
android_gravity: fill
android_12:
color: "#15B347"
image: "assets/android12splash.png"
icon_background_color: "#952727"
FLUTTER AND PACKAGE VERSION: Flutter (Channel stable, 3.3.10, on Microsoft Windows [versÆo 10.0.22000.1455], locale pt-BR) flutter_native_splash: ^2.2.17
Finally after spending hours searching, I found the solution.
I remembered that I had an older version of the app where the splashscreen worked without any problems. So I started comparing files by files, replacing them one by one, compiling and testing them directly on my Galaxy S10E.
I found a difference in the android/app/src/main/AndroidManifest.xml file, the worked version, has some lines, that does not exist in a new version. See below.
<application
android:label="aeroescuta"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="false">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
** JUST ADD THESE LINES **
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
So I put that part and the splashscreen started to work.
I tested it on another app with the same problem and it worked too.
@wesleytoshio Can you test it?
@jonbhanson I don´t have a technical explanation about it.
@paulobreim glad to hear you got it working.
@paulobreim glad to hear you got it working.
it is a bug's flutter or we will need to do it everytime?
I don't know why adding that line back in made it work. According to Flutter's docs, that line should be removed in Android 12.
@paulobreim Thank, It work.
https://github.com/jonbhanson/flutter_native_splash/issues/506#issuecomment-1407761555 @wesleytoshio I had same bug. But now, the bug was solved by adding code in AndroidManifest.xml.
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" /> // こっちを追加
@paulobreim https://github.com/jonbhanson/flutter_native_splash/issues/506#issuecomment-1407780313
It was big hint. Great appreciate!
@dai10512 @arno608rw @paulobreim do you have provideSplashScreen
implemented in your FlutterActivity
? In reading the Deprecated Splash Screen API Migration Guide, part of the instructions include removing provideSplashScreen()
in addition to removing the SplashScreenDrawable
from AndroidManifest.xml
. I suspect your problem may have come from removing one but not the other.
Finally after spending hours searching, I found the solution.
I remembered that I had an older version of the app where the splashscreen worked without any problems. So I started comparing files by files, replacing them one by one, compiling and testing them directly on my Galaxy S10E.
I found a difference in the android/app/src/main/AndroidManifest.xml file, the worked version, has some lines, that does not exist in a new version. See below.
<application android:label="aeroescuta" android:icon="@mipmap/ic_launcher" android:usesCleartextTraffic="false"> <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize" android:exported="true"> <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> ** JUST ADD THESE LINES ** <!-- Displays an Android View that continues showing the launch screen Drawable until Flutter paints its first frame, then this splash screen fades out. A splash screen is useful to avoid any visual gap between the end of Android's launch screen and the painting of Flutter's first frame. --> <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" /> So I put that part and the splashscreen started to work. I tested it on another app with the same problem and it worked too. @wesleytoshio Can you test it? @jonbhanson I don´t have a technical explanation about it.
Same problem here but removing SplashScreenDrawable is part of the migration to Android 12...
https://docs.flutter.dev/development/platform-integration/android/splash-screen-migration
That solution is strange... it is also specified that it could cause some crashes.
Or am I missing something?
That solution is strange... it is also specified that it could cause some crashes.
Do you mean this part?:
Delete the
meta-data
element, as Flutter no longer uses that, but it can cause a crash.
I understand this to mean that you should delete the meta-data
element because leaving it can cause a crash.
Same problem here
Were you able to solve the problem by following the migration guide?
That solution is strange... it is also specified that it could cause some crashes.
Do you mean this part?:
Delete the
meta-data
element, as Flutter no longer uses that, but it can cause a crash.I understand this to mean that you should delete the
meta-data
element because leaving it can cause a crash.
Yes. And that's why that solution seems strange to me.
Same problem here
Were you able to solve the problem by following the migration guide?
Nope. My app was already correct, there is neither provideSplashScreen, nor SplashScreenDrawable but at first start after install, no Launch Image is showed.
I did another test and it seems to me a problem related only to launching the application from Flutter (flutter run) and only on Android 12 devices.
In fact I tried to: 1 - Completely uninstall the app from your device 2 - Build the app in debug (flutter build apk --debug) 3 - Install the app on the device (flutter install --debug) 4 - Run the app directly in the device
The launch screen is always shown, even on first startup.
Finally after spending hours searching, I found the solution.
I remembered that I had an older version of the app where the splashscreen worked without any problems. So I started comparing files by files, replacing them one by one, compiling and testing them directly on my Galaxy S10E.
I found a difference in the android/app/src/main/AndroidManifest.xml file, the worked version, has some lines, that does not exist in a new version. See below.
<application android:label="aeroescuta" android:icon="@mipmap/ic_launcher" android:usesCleartextTraffic="false"> <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize" android:exported="true"> <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> ** JUST ADD THESE LINES ** <!-- Displays an Android View that continues showing the launch screen Drawable until Flutter paints its first frame, then this splash screen fades out. A splash screen is useful to avoid any visual gap between the end of Android's launch screen and the painting of Flutter's first frame. --> <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" /> So I put that part and the splashscreen started to work. I tested it on another app with the same problem and it worked too. @wesleytoshio Can you test it? @jonbhanson I don´t have a technical explanation about it.
@paulobreim It works for me, thanks
Finally after spending hours searching, I found the solution.
I remembered that I had an older version of the app where the splashscreen worked without any problems. So I started comparing files by files, replacing them one by one, compiling and testing them directly on my Galaxy S10E.
I found a difference in the android/app/src/main/AndroidManifest.xml file, the worked version, has some lines, that does not exist in a new version. See below.
<application android:label="aeroescuta" android:icon="@mipmap/ic_launcher" android:usesCleartextTraffic="false"> <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize" android:exported="true"> <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> ** JUST ADD THESE LINES ** <!-- Displays an Android View that continues showing the launch screen Drawable until Flutter paints its first frame, then this splash screen fades out. A splash screen is useful to avoid any visual gap between the end of Android's launch screen and the painting of Flutter's first frame. --> <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" /> So I put that part and the splashscreen started to work. I tested it on another app with the same problem and it worked too. @wesleytoshio Can you test it? @jonbhanson I don´t have a technical explanation about it.
I have spent nearly 6 hours searching for a solution. Thank you !
Hi friends,
My app doesn't show splashscreen on Android 12. I have a galaxy S10E and I used the following configuration:
The color #3A4F62 is displayed as the background and the default icon appears.
======================== In a second test, I just comment the specifications for Android 12
and... may be I found a new bug:
And when I compile I got this error
Looking the values-v31/styles.xml and values-night-v31/styles.xml we have
========================
What am I doing wrong?
Thank you Paulo