Flutter android grey screen in release mode even if there are no errors or red screens in debug mode

1,355

Solution 1

Nothing worked for me as there was no error in the UI. The error was at the beginning of the app in the main. After adding await before Firebase.initializeApp(); worked like miracle.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle(statusBarColor: Colors.transparent));
  **await** Firebase.initializeApp(); //adding await solved the problem
  SharedPreferences.getInstance().then((prefs) {
    var brightness = SchedulerBinding.instance.window.platformBrightness;
    if (brightness == Brightness.dark) {
      prefs.setBool('darkMode', true);
    } else {}
    var darkModeOn = prefs.getBool('darkMode') ?? false;
    runApp(
      ChangeNotifierProvider<ThemeNotifier>(
        create: (_) => ThemeNotifier(darkModeOn ? darkTheme : lightTheme),
        child: MaterialApp(
          home: root(),
        ),
      ),
    );
  });
}

Solution 2

Sometime it works well in debug mode but not working in release mode. You may catch that error by running below command in your terminal.

 flutter run --release 

The command compiles to release mode. When grey screen happened, you can check your debug console.

Share:
1,355
Jagadish
Author by

Jagadish

I develop cross-platform apps and websites. I have developed 3 android apps and published them on the Play Store, one of them is Just Meet with thousands of daily users. I have been coding from class 8 and have gained 3 years of experience with flutter language and android app development. I am a student of class 10 presently, I study all day and code at night. I believe in developing free or low-cost high-quality premium apps available to all the people of India. Recently I developed Just Meet, a video conferencing app that gives complete privacy, is secured and end to end encrypted, uses lesser data and battery, and works well in bad network areas like a charm and the best thing is it has no restriction on the number of participants or meeting duration and that too completely free! As I code alone it took me about 3 months to complete the initial release of it. It has a lot of features, some are new and very helpful. I believe this app will help a lot of people save their money and continue their meetings even in the worst network peacefully without having the tension of their user data! I have experience working on Firebase, Adsense, Admob, Facebook Audience Network, Unity Ads, etc, and also little in Python, Java, JavaScript, HTML, CSS, AIML. When am not studying and frustrated with bugs and errors usually spend my time working out on my muscles, painting, and playing with my pet dog "Ani".

Updated on December 25, 2022

Comments

  • Jagadish
    Jagadish over 1 year

    I am getting grey screen on startup just after the splash screen on android real device. I have solved all errors or red screens and after that tried again but still it remains the same.

    Note: I have released 2 versions of this app before this one to play store. So this is not the first one.

    My log

    Flutter run key commands.
    h Repeat this help message.
    c Clear the screen
    q Quit (terminate the application on the device).
    I/flutter (24661):                              <-- stops here nothing after this
    
    • sameer kashyap
      sameer kashyap over 3 years
      a grey screen most probably indicates a UI error such as null pointer exception. Could you post the code for which screen its showing grey?
    • Jagadish
      Jagadish over 3 years
      ok then its a ui error not a function error right?? As i have solved all function errors. Post the code...its showing at the start just after the splash screen i dont know for which page the problem has occurred.
    • Jagadish
      Jagadish over 3 years
      Is the problem at the starting page or it can be anywhere in the app? i asked this because its showing at the start just after the splash screen?
    • Jagadish
      Jagadish over 3 years
      @sameer kashyap I have editted the question...i hav added tht how app behaves in one of my phone in debug mode...it just gets stuck at installling... and tells signature diesnt matches in release mode but o another hone it shows grey screen in release mode and debug works fine.
    • sameer kashyap
      sameer kashyap over 3 years
      Then it Most probably in one of the widgets that's shown early on, have you tried debug mode again? it should certainly show up.
    • sameer kashyap
      sameer kashyap over 3 years
      is the data shown on the device consistent? Like if there's a empty field in your database for one of the user accounts, which is being accessed in the UI, it might cause.
    • Jagadish
      Jagadish over 3 years
      No i tried the dubg mode and visited evry page of my app and there was no error or red screen. And about the null data then i have solved it already by giving initial values. When i ran in release mode i got grey screen again.
    • Jagadish
      Jagadish over 3 years
      The log-> Running Gradle task 'assembleRelease'... Running Gradle task 'assembleRelease'... Done 692.3s (!) √ Built build\app\outputs\flutter-apk\app-release.apk (51.7MB). Installing build\app\outputs\flutter-apk\app.apk... 10.3s Flutter run key commands. h Repeat this help message. c Clear the screen q Quit (terminate the application on the device). I/flutter (17690): <- stopped here
    • Jagadish
      Jagadish over 3 years
      @sameerkashyap please invite others and your friends too...to help me please...so that it will be easy to track down the problem.
    • Jagadish
      Jagadish over 3 years
      the grey screen only related to my code error or it can be plugin error and build error or some android error????
    • Abhijith
      Abhijith over 3 years
      check your terminal for Incorrect usage of Parent Widget,the grey screen is a design issue it will work on debug mode,not release mode@Jagadish
    • Jagadish
      Jagadish over 3 years
      in debug mode no error is shown in the terminal... but after that also can aa error still exist?
    • Ali Qanbari
      Ali Qanbari over 3 years
      I had a similar issue. in my case, it was caused by not requesting device permissions correctly. check your permission code and only request permissions when it is not already granted.
  • Jagadish
    Jagadish over 3 years
    I am doing that only...it's shoeing grey screen and in debug console nothing shows up...please read my question again.?.I need help...
  • John Joe
    John Joe over 3 years
    I/flutter (17690): <- stopped here. It seems like you have use print to print out something? Did you use the above command to run it as release mode?
  • Jagadish
    Jagadish over 3 years
    No I haven't used print....the log stops there and yes I have used the command to run
  • Jagadish
    Jagadish over 3 years
    @sameer kashyap , @aligator , and @Assassin please help the log reader stops at I/flutter (17690): but it should show ` I/flutter (17690): completed or other things after that` i am afraid that its not a UI error maybe its some android build error or anything else please help me out....
  • John Joe
    John Joe over 3 years
    but it should show ` I/flutter (17690): completed or other things after that`.. Why would you expect it will show this? Please post the relevant code
  • Jagadish
    Jagadish over 3 years
    .....Because sometimes it woks automatically and then in the log it shoes all things like in debug mode but when it doesn't it gets stuck there. And more surprising is thats ten if there are no changes in code sometimes it works and sometimes it shoes grey screen.
  • John Joe
    John Joe over 3 years
    the grey screen normally stuck at which page? do you use any async-await on that page?
  • Jagadish
    Jagadish over 3 years
    The grey screen shoes just after thae splash screen...yes I use async and await on that page
  • Jagadish
    Jagadish over 3 years
    Actually I use a root page which decides either she duser to login page or main page...I use shared preference to get that user has signed in or not and then return the page.
  • John Joe
    John Joe over 3 years
    so the grey screen appear when first time sign in? Did you still get grey screen when open the app second time?
  • Jagadish
    Jagadish over 3 years
    No it appears every time...when the app starts just after the splash screen but sometimes it does work on its own and the app works then after wards without any change also it doesn't work...should I make a repository of my code on GitHub ?
  • Jagadish
    Jagadish over 3 years
    the grey screen just after indicates error at the beggining or the error can be anywhere in the app??
  • Jagadish
    Jagadish over 3 years
    Ok sure let me create a private repository only for teams and include you in it...you can also add your friends you know who can help...and yes thanks a lot for helping me in advance!!!
  • Jagadish
    Jagadish over 3 years
    does call Firebase.initializeApp(); in main cause the problem or the grey screen can only be for UI?
  • Jagadish
    Jagadish over 3 years