flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.11k stars 27.43k forks source link

iOS: Blank screen in running my flutter app in release mode #36247

Open hesham91fci opened 5 years ago

hesham91fci commented 5 years ago

Currently when running my app either from the terminal through the command flutter run -d "iPhone" --release or directly from xcode in release mode I got blank screen, and when inspecting the logs I can find the following error. Runner[3296:651656] [VERBOSE-2:engine.cc(116)] Engine run configuration was invalid. Runner[3296:651656] [VERBOSE-2:FlutterEngine.mm(294)] Could not launch engine with configuration. Kindly find below the output of flutter doctor

- Doctor summary (to see all details, run flutter doctor -v):
- [✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.5 18F132, locale en-EG)
- [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
- [!] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
-     ✗ CocoaPods not installed.
-         CocoaPods is used to retrieve the iOS platform side's plugin code that
-         responds to your plugin usage on the Dart side.
-         Without resolving iOS dependencies with CocoaPods, plugins will not work
-         on iOS.
-         For more info, see https://flutter.io/platform-plugins
-       To install:
-         brew install cocoapods
-         pod setup
- [✓] Android Studio (version 3.2)
- [✓] Connected device (2 available)

Any help would be appreciated, thanks in advance :)

hesham91fci commented 5 years ago

@jamesderlin any help would be appreciated Thanks in advance

shinayser commented 5 years ago

Check this: https://github.com/flutter/flutter/issues/22188#issuecomment-451427968

juanjoserodrigolazaro commented 5 years ago

Same here, any solution? I dont have doctor issues!

hesham91fci commented 5 years ago

Check this: #22188 (comment)

I tried flutter build ios --release then flutter run -d "iPhone" --release but same behavior happens (Blank screen) @shinayser @zoechi Please any help would be appreciated

leonardop21 commented 5 years ago

GoogleService-Info inside the runner/runner folder inserted through x-code, I followed all the recommended steps, even though the application when sent to production gets the white screen when starting.

Flutter clean flutter build ios --release

Xcode Product -> Clean Archive Upload App Store

But I have the same problem. Any idea what that might be?

dnfield commented 5 years ago

Can you try this on the latest stable, and make sure to thoroughly clean your project?

This error normally means that something is off with the AOT blob. It could be that it was built with the wrong version of Dart somehow, or it could be that the build system got confused and isn't giving you the right artifact. 1.2.1 is two stable releases behind the latest stable at this point though,s o it would be good to try on latest stable first.

steelhearts commented 5 years ago

I have the same problem

In my case it happened after updating from 1.5.x to 1.7.8 + hotfix.3

I thought that trash was accumulated in the build folder etc.

So I deleted the build folder and the Derived Data folder, but the result did not change

Jul 18 14:30:42 ALEXANDER Runner(Flutter)[11428] <Notice>: [VERBOSE-2:engine.cc(118)] Engine run configuration was invalid.
Jul 18 14:30:42 ALEXANDER Runner(Flutter)[11428] <Notice>: [VERBOSE-2:FlutterEngine.mm(308)] Could not launch engine with configuration.

Execution result of Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.14.5 18F132, locale ja-JP)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
    ✗ Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.4)
[✓] Connected device (1 available)

it worked fine until last week. . .

dnfield commented 5 years ago

Another possibility is that the cache is out of sync.

Try removing the bin/cache folder from you flutter checkout. It should automatically regenerate and may fix this.

steelhearts commented 5 years ago

Try it in a local environment and it works well.

But the flutter project on CircleCI also has the same problem...

It happens with ipa files output to circleci artifacts. . .

pbouttier commented 5 years ago

I have the same problem, I have reverted to 1.5.4 and did flutter clean, and then flutter build ios --release and it's working.

I doesn't know if the problem came from the new version, of if i miss the build release part first.

juanjoserodrigolazaro commented 5 years ago

Which command do you use to revert it?

juanjoserodrigolazaro97 commented 5 years ago

I paste the logs of xcode when running the release version:

2019-08-14 17:24:05.665679-0400 Runner[6832:1874400] [DYMTLInitPlatform] platform initialization successful W0814 17:24:06.374780 1 commandlineflags.cc:1503] Ignoring RegisterValidateFunction() for flag pointer 0x104b674d0: no flag found at that address 2019-08-14 17:24:06.884275-0400 Runner[6832:1874211] [VERBOSE-2:dart_vm_data.cc(19)] VM snapshot invalid and could not be inferred from settings. 2019-08-14 17:24:06.884309-0400 Runner[6832:1874211] [VERBOSE-2:dart_vm.cc(238)] Could not setup VM data to bootstrap the VM from. 2019-08-14 17:24:06.884320-0400 Runner[6832:1874211] [VERBOSE-2:dart_vm_lifecycle.cc(89)] Could not create Dart VM instance. 2019-08-14 17:24:06.884374-0400 Runner[6832:1874211] [VERBOSE-3:shell.cc(218)] Check failed: vm. Must be able to initialize the VM.

also throws a signal SIGABRT on flutterappdelegate

pbouttier commented 5 years ago

Which command do you use to revert it?

git checkout v...... ex: git checkou v1.5.4-hotfix.2

then run flutter doctor and check if everything is ok

AchSum commented 5 years ago

Check this: #22188 (comment)

I tried flutter build ios --release then flutter run -d "iPhone" --release but same behavior happens (Blank screen)

maybe you need to update cocoapods

charleshan commented 5 years ago

This occurred for me as well. I fixed it by running flutter clean and rebuilding the release.

Screenshot_2019-09-06-15_23_55

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.6 18G95, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.5)
[✓] Android Studio (version 3.5)
[✓] Connected device (2 available)

• No issues found!
dnfield commented 5 years ago

/cc @jonahwilliams @jmagman - this seems like a stale-ios-build cache issue.

jonahwilliams commented 5 years ago

Another victim of https://github.com/flutter/flutter/issues/16604

dnfield commented 5 years ago

Should we close it as a duplicate?

jonahwilliams commented 5 years ago

Yes, while the exact cause may be different the ultimate fix is the same (move the build to assemble)

charleshan commented 5 years ago

I spoke too soon. flutter clean doesn't always fix the issue. What's more frustrating is that it seems to be happening randomly. Sometimes flutter clean fixes the issue and sometimes it doesn't.

jonahwilliams commented 5 years ago

If flutter clean doesn't fix the issue then it is almost certainly not #16604, since that does remove almost every file created by flutter.

sglim commented 5 years ago

In my case, I fixed this issue by upgrading my Cocoapods version to the recent one. Flutter doctor should include version check for valid Cocoapods. (Is it available now?)

My flutter version was recent stable (1.7.8+hotfix.4)

TheColdVoid commented 5 years ago

I solve this problem by:

  1. add export NO_PROXY=localhost,127.0.0.1 to ~/.bashrc ( or ~/.zshrc if you use zsh )
  2. flutter clean
  3. close all IDE and simulator
  4. re-run debug and then it worked;

I don't know if this solution doesn't work for you.

dakt commented 5 years ago

Same here. I pushed app via Firebase App Distribution. Tried flutter clean beforehand but didn't work.

LOG-TAG commented 5 years ago

@dakt same here , found any work around ? Xcode 11.1 ? What is the cocoa pod version you are using ? It's firebase distribution problem or xcode or cocoa pod version ?

jamesdixon commented 5 years ago

Interestingly enough, I'm running into this only when building with the --debug flag using CodeMagic CI. Running with --release works 🤔

sunjianan9900 commented 5 years ago

GoogleService-Info

same issue and i don't know why my GoogleService-Info can not link to firebase

sunjianan9900 commented 5 years ago

I fix this issues by

1.open Xcode - product - clean 2.Do what you need in Xcode (change build code ...) 3.Flutter clean - Flutter build ios --release 4.open Xcode - Do not change anything - product - Archive

mayur1407 commented 5 years ago

I started getting this error when I followed the command to regenerate the podfile.:

Warning: Podfile is out of date
This can cause a mismatched version of Flutter to be embedded in your app, which may result in App Store submission rejection or crashes. If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/24641 for instructions. To regenerate the Podfile, run: rm ios/Podfile

Unable to see the app. Only white screen is showing. Any luck to anybody to resolve this?

Thanks in advance.

jmagman commented 4 years ago

I started getting this error when I followed the command to regenerate the podfile.:

Warning: Podfile is out of date This can cause a mismatched version of Flutter to be embedded in your app, which may result in App Store submission rejection or crashes. If you have local Podfile edits you would like to keep, see #24641 for instructions. To regenerate the Podfile, run: rm ios/Podfile

Unable to see the app. Only white screen is showing. Any luck to anybody to resolve this?

Thanks in advance.

@mayur1407 After you deleted ios/Podfile how are you running the app?

mayur1407 commented 4 years ago

while building it, Flutter creates the podfile again. I am suspecting this error caused due to using a Flutter's master channel. I had to uninstall FLutter and used the stable channel.

shriharip commented 4 years ago

I have similar issue. Flutter clean and build ios. Shows only blank screen. Used firebase app distribution and first time it was working. After Flutter clean and build release for the next update. it shows only blank screen. Firebase crashlytics shows no crashes Used TestFlight.. No crashes but same issue. Blank white screen.

Working fine in simulator both ios and android. No Doctor issues.

shriharip commented 4 years ago

I don't know if I need to create a new issue or contribute here. Please help me out.

FLUTTER CLEAN IS NOT HELPING..

My release is not working and it is a blank screen. flutter doctor v

[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.14.6 18G103, locale en-DK) • Flutter version 1.12.13+hotfix.6 at /Users/hari/flutter • Framework revision 18cd7a3601 (4 days ago), 2019-12-11 06:35:39 -0800 • Engine revision 2994f7e1e6 • Dart version 2.7.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1) • Android SDK at /Users/hari/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.1 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 11.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3, Build version 11C29 • CocoaPods version 1.7.5

[✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 42.0.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.41.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.7.1

[✓] Connected device (1 available) • my iPhone • f09803ea7ec3798bcd3f83c045cd559ebe57777c • ios • iOS 13.3

On ios-Simulator the app runs and it is not showing any errors.

On-device when I do flutter run --release it is a blank screen ... no logs (connected physcially)

I build and distribute via test flight or firebase distribution, then blank screen. No errors while building and archiving.

mayur1407 commented 4 years ago

@shriharip : Did you try switching the channel to stable?

mayur1407 commented 4 years ago

calling WidgetsFlutterBinding.ensureInitialized() in main function before runApp() call should work. In my case, I called WidgetsFlutterBinding.ensureInitialized() before calling SystemChrome.setPreferredOrientations and it worked. Hope it will help.

shriharip commented 4 years ago

@mayur1407 . Thanks, but I am calling WidgetsFlutterBinding.ensureInitialized() :(

shriharip commented 4 years ago

channel to stable?

@mayur1407 I am on the stable channel now and all the 7 test devices are facing this issue The first release to the phone does not have this problem. Subsequent releases on top of the app results in blank screen Also, uninstall and reinstall of the app on the phone does not help. it is still a blank screen. Not able to move to release since testing is halted.

Plz any suggestions or help.

mayur1407 commented 4 years ago

Hi @shriharip , This happens due to a crash while launching the app. Hence, the white screen persists. It does not provide any detail for Flutter run command. I would suggest you run the app in debug mode and this will provide you logs. You can share the logs here or the code of the main file.

shriharip commented 4 years ago

@mayur1407 Thanks again

The problem is when it is in Simulator it runs fine, but on the device, it is the problem. And the first time I run the app it opens and any subsequent updates will result in blank screen.

Here the logs when I do flutter run --verbose-system-logs [10:11:08]

Launching lib/main.dart on PRDI’s iPhone in debug mode... Found saved certificate choice "Apple Development: (6ZCHK85DT4)". To clear, use "flutter config". Signing iOS app for device deployment using developer identity: "Apple Development: (6ZCHK85DT4)" Running pod install... 10.8s Running Xcode build...

├─Assembling Flutter resources... 11.7s └─Compiling, linking and signing... 8.6s Xcode build done. 79.3s Installing and launching... 23.9s Syncing files to device PRDI’s iPhone...
8,450ms (!)

🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R". An Observatory debugger and profiler on PRDI’s iPhone is available at: http://127.0.0.1:1024/r9DOFofxgZ0=/ For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".

If this is of any help image

code related to app

import 'dart:async';

import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:minlandsby/core/utils/global_translations.dart';
import 'package:minlandsby/config/provider.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';

import 'minlandsby.dart';
import 'package:hive/hive.dart';

void main() async {
  // Provider.debugCheckInvalidValueType = null;

  // Crashlytics.instance.enableInDevMode = true;

  // Pass all uncaught errors from the framework to Crashlytics.
  FlutterError.onError = Crashlytics.instance.recordFlutterError;

  WidgetsFlutterBinding.ensureInitialized();
  await allTranslations.init();
  var dir = await getTemporaryDirectory(); //neeed to change this later
  Hive.init(dir.path);

  runApp(MinLandsby());
  // runZoned(() {
  //   runApp(MinLandsby());
  // }, onError: Crashlytics.instance.recordError);
}
import 'package:flutter/material.dart';
import 'package:minlandsby/config/provider.dart';
import 'package:minlandsby/ui/router.dart';
import 'package:provider/provider.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:minlandsby/core/utils/global_translations.dart';
//import 'package:minlandsby/utils/route_generator.dart';
import 'package:minlandsby/ui/common/theme.dart';
import 'core/constants/app_constants.dart';

class MinLandsby extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: providers,
      child: MaterialApp(
        title: 'MinLandsby',
        localizationsDelegates: [
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
          GlobalCupertinoLocalizations.delegate,
        ],
        supportedLocales: allTranslations.supportedLocales(),
        theme: myTheme,
        debugShowCheckedModeBanner: false,
        showPerformanceOverlay: false,
        initialRoute: RoutePaths.Home,
        onGenerateRoute: Router.generateRoute,
      ),
    );
  }
}
shriharip commented 4 years ago

One thing I have found out is when the device is connected and I run flutter run it shows blank screen

Then when I do a hot restart (and rebuild state), after pressing "R". The app launches I feel it is something to do with the state re building.

But on Simulator I don't even have to do a hot restart, it works fine each time.

However, I do not find this issue with the android build. when I also do apk distribution, it works fine on test devices.

shriharip commented 4 years ago

Ok, I don't know how much of this might be beneficial for others, but there was one thing that helped me find the bug and mostly resolved this error.

First thing, the app was using Localizations. And I was using the approach mentioned in this article https://www.didierboelens.com/faq/week1/

As you can see in the above main method, it is async and I await for the translations init .

await allTranslations.init();

this is the init call


///
  /// One-time initialization
  ///
  Future<Null> init() async {
    if (_locale == null) {
      await setNewLanguage();
    }
    return null;
  }

  ///
  /// Routine to change the language
  ///
  static void setNewLanguage([String newLanguage]) async {
    String language = newLanguage;
    if (language == null) {
      language = await preferences.getPreferredLanguage();
    }

    // If not in the preferences, get the current locale
    if (language == '') {
      String currentLocale = Platform.localeName.toLowerCase();
      if (currentLocale.length > 2) {
        if (currentLocale[2] == "-" || currentLocale[2] == "_") {
          language = currentLocale.substring(0, 2);
        }
      }
    }

    if (!_kSupportedLanguages.contains(language)) {
      language = "";
    }

    // Set the locale
    if (language == "") {
      language = preferences.defaultLanguage;
    }
    _locale = Locale(language, ' ');

    // Load the language strings
    String jsonContent = await rootBundle
        .loadString("assets/locale/locale_${_locale.languageCode}.json");
    _localizedValues = json.decode(jsonContent);

    // Clear the cache
    _cache = {};
  }

If I debug and go step by step, then there are no errors and there is no blank screen. But if I run it directly either the await did not wait or the shared preferences were not set properly.

So now I have moved this to the Provider, put in some static calls and removed the await from main method. Also, in Material app, I am directly specifying the supported Locales using const Locale constructor instead of passing them through the above method.

Right now the app loads and there is no blank screen.

I did not deep dive into the problem, but on the onset, it looks like the first call Preferences are not set properly or the platform Locale is not captured properly.

I still do not know, why it was working fine on simulators, but it is clear that the devices the locale might be the issue (setter and getter )

mayur1407 commented 4 years ago

Great! Thanks for sharing analysis also. :)

shriharip commented 4 years ago

oh my god !!.. New year and this problem struck again. :(

This time, the app runs when connected to the device and also on simulator, but the release is creating a blank screen.

Log on running on the device. Launching lib/main.dart on PRDI’s iPhone in debug mode... Found saved certificate choice "Apple Development: TEAM NAME (TEAMID)". To clear, use "flutter config". Signing iOS app for device deployment using developer identity: "Apple Development: TEAM NAME (TEAMID)" Xcode build done. 156.5s

carta1 commented 4 years ago

I am experiencing a similar issue, I extracted the app ipa (IOS side) using adhoc settings, distribute the app to a tester using firebase app distribution and the app either does not open or stay on a blank white screen. The app works fine on android test devices, and also works on emulators both ios and android emulators, if iphone is connected directly to the computer and app is added using xcode, the app works.

shriharip commented 4 years ago

exactly. I just created a new issue with more logs .. maybe i should have done here but thought it is best to create one #48403

imkarthikb commented 4 years ago

Faced this issue where the app was working in android-debug, android-release and ios-debug, but was showing blank screen (as seen in #48403) in ios-release mode. Had implemented localisation in the app and was using localeResolutionCallback in the MaterialApp. Replacing the localeResolutionCallback with localeListResolutionCallback fixed this issue for me.

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale
    en-IN)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.41.1)
[✓] Connected device (3 available)

• No issues found!
dnfield commented 4 years ago

At a high level, this issue is the app failing to start because of some error that causes failure early in the startup process of the app.

Typically, this is caused because of a bad build getting sent to the phone, or because the phone's version of the app has become corrupted.

The bad build can happen because of stale local build artifacts, or because of an error in user code.

The corrupted app is something I've seen but I'm not sure how it happens.

The resolution tends to be something like:

  1. Try running your app from Xcode. See what the debugger tells you. It almost always can give you more information than the tool in this case, because frequently when this happens the tool can't even connect to the app (but Xcode can via LLDB).
  2. Try cleaning your local project (flutter clean, and perhaps open in Xcode and use Xcode to clean the workspace as well).
  3. Try removing the app from the device (long press the icon, delete the application), and then re-deploying.

Unfortunately, this bug is becoming one of those many problems with the same manifestation issues - there are a lot of ways to get here, and there's no one fix for all of them.

shriharip commented 4 years ago

@imkarthikb . thanks again, my friend.

craiglabenz commented 4 years ago

Try running your app from Xcode. See what the debugger tells you. It almost always can give you more information than the tool in this case, because frequently when this happens the tool can't even connect to the app (but Xcode can via LLDB).

This is what solved it for me. In my case, I had some environment (dev vs staging vs prod) config code that worked in VS Code, but not in a release build. Added null checks to that and viola. Obviously my specific solution is not helpful to anyone else, but running the app in Xcode immediately revealed the issue.

jmagman commented 4 years ago

This looks like a combination of: https://github.com/flutter/flutter/issues/37850 https://github.com/flutter/flutter/issues/24641 https://github.com/flutter/flutter/issues/16604 (mitigated by https://github.com/flutter/flutter/pull/38992) https://github.com/flutter/flutter/issues/22536 https://github.com/flutter/flutter/issues/19196

Random things reported in this issue to have worked:

You can see from that list that this issue isn't tracking any cause, just a "white screen" symptom. See @dnfield's explanation: https://github.com/flutter/flutter/issues/36247#issuecomment-572151934

So instead of using this bug to track various symptoms, maybe the engine should crash the app instead of just logging if the VM can't be created? At least users would get crash reports... https://github.com/flutter/engine/blob/master/runtime/dart_vm_data.cc