androidflutterandroid-gradle-pluginandroid-emulatorlaunch

Flutter's Android Apps white out on the second run or later, if without the Emulator's 'Wipe Data'


The app ran well the first time with no problem. But then when I stopped the program and ran it again, the emulator failed to launch the app and whited out like the following picture, without throwing any errors.

Emulator whited out

Console:

Launching lib\\main.dart on sdk gphone16k x86 64 in debug mode...

Running Gradle task 'assembleDebug'...

√ Built build\\app\\outputs\\flutter-apk\\app-debug.apk

Debug service listening on ws://127.0.0.1:53998/JPrAPAtzNX8=/ws

Syncing files to device sdk gphone16k x86 64...

I/le.test_project( 7228): Compiler allocated 5174KB to compile void android.view.ViewRootImpl.performTraversals()

Result of flutter doctor -v as follows:

PS D:\Development\flutter\test_project> flutter doctor -v
[√] Flutter (Channel stable, 3.22.3, on Microsoft Windows [Version 10.0.22631.3958], locale en-US)
    • Flutter version 3.22.3 on channel stable at C:\Users\BlueZ\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (10 days ago), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\BlueZ\AppData\Local\Android\Sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.10.35013.160
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)

[√] VS Code (version 1.91.1)
    • VS Code at C:\Users\BlueZ\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.92.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22631.3958]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 127.0.6533.72
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 127.0.2651.74

[√] Network resources
    • All expected network resources are available.

• No issues found!

If I 'Wipe Data' the emulator, it runs fine again, but if not, it fails.

I made new Flutter projects (default counter) and the problem happened to them too. But it didn't happen to Java default projects. So I guess it's caused by flutter projects' settings or sth.

'Invalidate Caches...' didn't change a thing. I tried migrating gradle files to a new syntax according to this link: https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply

I also went to 'Project Structure' => 'SDK' and set it to 'Android API 35, extension level 13 Platform' which is the emulator I'm using currently. Not a change.

I reinstalled Flutter SDK / Java JDK / Android Studio, with any personal settings. Didn't work.

It's annoying and inefficient having to 'Wipe Data' the emulator every time I run an app.

No idea how to solve it. Any advice would help. Thanks in advance.


Solution

  • I experienced the same issue.
    Please check if disabling hardware acceleration and starting the application resolves the issue:

    flutter run --enable-software-rendering
    

    This issue is probably the same as the one being discussed in this thread: https://github.com/flutter/flutter/issues/146890

    When placing a button, it is not visible but can be tapped, so it seems to be an emulator rendering issue.
    I decided to choose 'ANGLE' in the emulator settings to fix the hardware acceleration.

    I decided to choose 'ANGLE' in the emulator settings to use the software acceleration.

    Android Emulator setting Dialog
    In the emulator toolbox, go to '...' → Settings → Advanced tab → set OpenGL ES renderer to 'ANGLE(D3D11)' and restart the emulator.

    Note:
    Selecting hardware acceleration worked on first run, but the issue reoccurred after uninstalling and reinstalling the app. It does not reoccur with software acceleration.

    Other solutions from this thread: