jonbhanson / flutter_native_splash

Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image.
https://pub.dev/packages/flutter_native_splash
MIT License
1.36k stars 215 forks source link

Default splash screen persists after following the setup steps #612

Closed ivanhercaz closed 1 year ago

ivanhercaz commented 1 year ago

Describe the bug

Splash screen is showing the same color and icon after follow all the required steps in the documentation of the package. I even tried to clean all the data of application in the smartphone, uninstall it, restart and install it again. I also retry all the process with a totally new application.

I really don't think it may be a real bug, but maybe some misunderstanding I am having, although it seems very simple, so I have not clear what is wrong.

Configuration

flutter_native_splash:
  color: "#ff0000"
  color_dark: "#ff0000"
  image: "assets/logo.png"
  image_dark: "assets/logo.png"
  android12:
    color: "#ff0000"
    color_dark: "#ff0000"
    image: "assets/logo.png"
    image_dark: "assets/logo.png"

Device (please complete the following information):

To Reproduce Steps to reproduce the behavior, using the example app:

  1. Add flutter_native_splash: ^2.3.4 to dependencies.
  2. Set the splash screen (above configuration).
  3. Run the create command: dart run flutter_native_splash:create
  4. flutter run and check the log attached below to see if there is some error (it seems not):
[flutter_application_1] flutter run                                   main  ✈ ✱
Launching lib/main.dart on RMX3710 in debug mode...
Running Gradle task 'assembleDebug'...                             12,3s
✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app-debug.apk...           3,9s
Syncing files to device RMX3710...                                  69ms

A Dart VM Service on RMX3710 is available at:
http://127.0.0.1:39393/CporL13lIik=/
I/mali    (16469): [DebugProp] GPU Debug-Mechanism Disable !
D/hw-ProcessState(16469): Binder ioctl to enable oneway spam detection failed: Invalid argument
The Flutter DevTools debugger and profiler on RMX3710 is available at:
http://127.0.0.1:9104?uri=http://127.0.0.1:39393/CporL13lIik=/
D/BLASTBufferQueue(16469): [SurfaceView[com.example.flutter_application_1/com.example.flutter_application_1.MainActivity]#1](f:0,a:1) acquireNextBufferLocked size=1080x2268 mFrameNumber=1 applyTransaction=true mTimestamp=845747668434(auto) mPendingTransactions.size=0 graphicBufferId=70733816397824 transform=0
D/VRI[MainActivity](16469): registerCallbacksForSync syncBuffer=false
D/BLASTBufferQueue(16469): [VRI[MainActivity]#0](f:0,a:1) acquireNextBufferLocked size=1080x2400 mFrameNumber=1 applyTransaction=true mTimestamp=845802004434(auto) mPendingTransactions.size=0 graphicBufferId=70733816397826 transform=0
D/VRI[MainActivity](16469): Received frameCommittedCallback lastAttemptedDrawFrameNum=1 didProduceBuffer=true syncBuffer=false
W/Parcel  (16469): Expecting binder but got null!
D/VRI[MainActivity](16469):  debugCancelDraw  cancelDraw=false,count = 240,android.view.ViewRootImpl@3813173
D/VRI[MainActivity](16469): draw finished.
D/VRI[MainActivity](16469): onFocusEvent true
D/OplusScrollToTopManager(16469): com.example.flutter_application_1/com.example.flutter_application_1.MainActivity,This DecorView@dcece18[MainActivity] change focus to true

The only suspicious log line is:

W/Parcel  (16469): Expecting binder but got null!

But that's related with not having WidgetsFlutterBinding.ensureInitialized(); before runApp(const MyApp());, but doesn't affect to have it.

Additional context

As I commented above, I really don't have clear if it is a bug or something I configured wrong, but it seems really strange to me because it even happens with a new application.

android/app/src/main/res/drawable/launch_background.xml file has the correct code:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <bitmap android:gravity="fill" android:src="@drawable/background"/>
    </item>
    <item>
        <bitmap android:gravity="center" android:src="@drawable/splash"/>
    </item>
</layer-list>

Same in the other cases and in drawable-hdpi and other related directories, the splash.png is the correct image. The Flutter logo is just in mipmap-* for the icon launcher, ic_launcher.png. In values/styles.xml there is:

<item name="android:windowBackground">@drawable/launch_background</item>

Does someone has any idea? Thank you very much in advance!

Regards, Iván

ivanhercaz commented 1 year ago

Well, a bit of progress. The same configuration in a different app works on iOS:

I will try to test it in another Android device to discard if it is just a problem with my current smartphone. I will also test the another sample app I am using for Android.

jonbhanson commented 1 year ago

You may want to try it on an Android emulator. Sometimes the Android clone operating systems do not implement their splash screens according to the Android API.

ivanhercaz commented 1 year ago

@jonbhanson, I tried just now with an Android emulator (Pixel 2 XL API 31) but it doesn't work either. Strange...

ivanhercaz commented 1 year ago

@jonbhanson, already found my error and I could confirm it was an error and not a bug! Looking on res directory I decided to check the values-v31/styles.xml and I saw there isn't any mention to the background color nor the icon nor the launcher theme. I edited it manually and it works.

I decided to reread one more time my configuration and I saw the error android12 must be android_12... I don't know why I didn't see it before, I think I need to sleep more 😅 .

Thank you for your attention and for this awesome package! It saves a lot of time. When I have a little more economic slack, I will invite you to a coffee!

jonbhanson commented 1 year ago

Thanks for the feedback @ivanhercaz and I'm glad you got it resolved. This gives me an idea though: the package should check each parameter and give the user an error message on an invalid parameter. I'll see if I can add this in the next version.

ivanhercaz commented 1 year ago

This gives me an idea though: the package should check each parameter and give the user an error message on an invalid parameter.

Wow! That's a great idea and a helpful hint help for distracted people like me 😅 .