flutter android app freezes on the splash screen in release mode
Asked Answered
P

9

7

I have a problem using the storage to persist the user login data .

the scenario like that : after login , I clear the app and try to reopen it again , sometimes it open and sometimes it's freezes on the splash screen. this only happen in the release mode .

I tried to remove every package until I found the problem with using the storage after login. so I if I not login nothing freezes .

I used get_storage and shared_preferences and secured_storage packages but nothing changed . flutter 2.10.2.

tested on real device

also this the the used packages

module:
  androidX: true # Add this line.

environment:
  sdk: ">=2.11.0 <3.0.0"

dependencies:
  dio: ^4.0.0
  get: ^4.1.4
  get_storage:
  flutter:
    sdk: flutter


dev_dependencies:
  flutter_launcher_icons: ^0.9.2

flutter_icons:
  android: true
  ios: false
  image_path: "assets/icons/launcher_icon.png"
  flutter_test:
    sdk: flutter

name: delivery
description: manager App
version: 1.6.3
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

finally I decided to share the verbose hope someone can help

https://github.com/flutter/flutter/issues/98862

Perak answered 20/2, 2022 at 19:33 Comment(8)
Is this freezing only on an emulator? Have you tested this on a real device as well?Quackery
it's freezes on real device when use release mode , but in debug mode no problemPerak
You could try 1) removing components until it works... or 2) print debugging each step so you know where it gets stuck. This won't fix the problem but it will tell you what the problem is.M16
about 1 , the stuck happen after login and clear all apps and then run the app , which means something happen with the login storage , but i can not remove the storage about 2 , nothing shown in the logcat or in the run or any exceptionPerak
There might be some permission issue like internet. make sure you have mentioned them. Another way to find out problem is via logs. use flutter logs command and connect your device via cable and run release version of your app after installing it. Check for logs. hope it will helpBinah
shouldn't flutter_native_splash in dependencies: block instead of dev_dependencies:?Mosstrooper
Remove flutter_native_splash: ^2.0.4 plugin and try with medium.com/flutter-clan/…Schock
i removed it and try with a new flutter project without any splash screen but it's still stopped on the black splash screen without any errorPerak
B
5

I had the same problem in our production app few days back. I released an update (where just a couple of tables were updated in the local app database) with Flutter 2.10.2 and many users started getting frozen launch screen.

After spending days trying to solve it, I finally downgraded the Flutter to 2.8 and released an update and the issue was gone.

Bunkhouse answered 25/2, 2022 at 18:2 Comment(1)
thank you @Mohammad Tanvir Parvez , after couple of days and about 100 tries for all solutions , your suggestion the only one worked for me .Perak
S
14

I had a similar bug:

  • By default on Android, android:allowBackup is set to true which means that your app's data is automatically backed up to your Google Drive
  • The problem is when something in your data structure changes but you have an old backup with an old and incompatible data structure. When reinstalling a new version of the app which is incompatible with the old data structure which was backed up, it will freeze on the native splash screen.

I solved this by adding android:allowBackup="false" to android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    <application
        ...
        android:allowBackup="false"
        ...
    </application>
</manifest>

Shaylashaylah answered 25/2, 2022 at 16:25 Comment(0)
B
5

I had the same problem in our production app few days back. I released an update (where just a couple of tables were updated in the local app database) with Flutter 2.10.2 and many users started getting frozen launch screen.

After spending days trying to solve it, I finally downgraded the Flutter to 2.8 and released an update and the issue was gone.

Bunkhouse answered 25/2, 2022 at 18:2 Comment(1)
thank you @Mohammad Tanvir Parvez , after couple of days and about 100 tries for all solutions , your suggestion the only one worked for me .Perak
H
2

You could install sentry_flutter in your application to capture exceptions in your release app.

Also, try moving flutter_native_splash: ^2.0.4 from dev_dependencies to dependencies.

Haggi answered 24/2, 2022 at 12:59 Comment(3)
i am already using it but it not catch any error , because actually there is no exception , just the app stopped in the splash screen and display this message { app not responding }Perak
@Perak I added another suggestion to my answer.Haggi
I already removing it when trying to fix this issue but it still remainingPerak
B
1

Take you real device and connect it to you pc via cable and install release version of you app

  1. Go-to terminal and run flutter logs to see what's going on

  2. In some cases, may be permissions are reason. You need to specify them (don't relax because of default permissions set)

Binah answered 23/2, 2022 at 9:6 Comment(4)
i use this command flutter run --release after the app running there is no way to run any other command until stop the execution , so there is no way to use flutter logs or any commandPerak
when flutter build completes, install app to you phone. then connect it to your machine and open new and fresh session/instance of terminal/command prompt and then run flutter logs. Then start your app from that device you've installed app on. You will see logs in terminal. (Make sure to enable usb debugging in Developer options)Binah
nothing , no error in the logPerak
I didn't know this flutter logs command. The output gave me a good hint about the cause of the problem. Seems the different keys of a test app and release app for secure storage were the cause. Thanks a lot.Flashover
A
0

I think there should be 2 things --

first make sure you added the Internet permission and other required permissions in AndroidManifest.xml file

Second if you already defined all the required permissions then try this--

in your app/build.gradle file add these 3 lines

        minifyEnabled false
        useProguard false
        shrinkResources false

in

buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
            minifyEnabled false
            useProguard false
            shrinkResources false
        }
    }

then clean your project and try again I hope this will work and if you still faced that problem check the documentation again of flutter_native_splash package you used, also watch the video of Johannes Milke's tutorial which is already linked in the documentaion.

Thankyou.

Ailanthus answered 23/2, 2022 at 18:50 Comment(8)
after adding the three lines i show this error * What went wrong: A problem occurred evaluating project ':app'. > No signature of method: build_1icb3k0ev7h17j94toyq7e1sh.android() is applicable for argument types: (build_1icb3k0ev7h17j94toyq7e1sh$_run_closure3) values: [build_1icb3k0ev7h17j94toyq7e1sh$_run_closure3@392a11c2]Perak
also i removed flutter_native_splash and start new project from scratch without any splash configation but it still stopped on the the black screen untill show this message {app not responding }Perak
then you must try a new project and try to run that with adding anything, also before that run the command flutter doctor -v in the terminalAilanthus
that what i told above , i started new project from scratch but still hang on the default black splash without any issue in the logPerak
You are running your app on emulator or on the real device?Ailanthus
real device using the release mode , the debug mode worked correctlyPerak
if you getting that error after adding those 3 lines please check this post #61808020Ailanthus
after adding the three lines and fixed the issue , nothing changed thank youPerak
H
0

Since the other answers haven't given any luck, I would suggest that you start by disabling everything in your app, and gradually enable portions of the app until you reproduce the problem. For example, start by replacing your MyApp() in your main() with a blank shell of an app:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
    statusBarColor: Colors.transparent, // transparent status bar
  ));
  await initServices();
  runApp(MaterialApp(
    home: Container(color: Colors.blue),
  ));
}

This will tell you if the problem is in your initialization or the rest of your app. If the blue screen loads, it tells you that the initialization is fine. Keep dividing your app like this until you find the part this is causing the app to hang.

Haggi answered 25/2, 2022 at 2:54 Comment(1)
the issue happen only after login , i updated the answer for more clearPerak
T
0

I recommend you to install the flutter sdk again from scratch and try it.

Thai answered 25/2, 2022 at 4:47 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Joashus
thanks i updated the question to clarify what going on exactly @AbhishekDuttPerak
L
0

oddly enough, the note of the phone connection cable helped me. I've been trying to figure out what's going on for almost a month, but to no avail. Although the cable worked as it should, transmitted information from the device and charged, it was the build of the application that was not installed with it. Try simply changing the plug-in cable to the device.

Lipoid answered 3/9, 2024 at 10:51 Comment(0)
S
0

I am facing the same problem & my app was rejected on play store reason was Issue found: Violation of Broken Functionality policy and Your app contains content that isn’t compliant with the Broken Functionality policy.

App installs, but doesn't load

I figure out several way. If you are using flutter_native_splash plugin dependency If you do not need to use the preserve() and remove() methods, you can place the flutter_native_splash dependency in the dev_dependencies section of pubspec.yaml.

You have to modified android/app/build.gradle and add multiDexEnabled true

    defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId = "com.your.appid"
    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    minSdk = 21
    targetSdk = 35
    versionCode = flutterVersionCode.toInteger()
    versionName = flutterVersionName
    multiDexEnabled true
}

This help me to launch my app quickly and help me to resolve this issue!

Starks answered 1/10, 2024 at 18:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.