Flutter 出现白屏问题

Posted

技术标签:

【中文标题】Flutter 出现白屏问题【英文标题】:Flutter Getting White Screen Issue 【发布时间】:2019-03-23 16:27:08 【问题描述】:

我是 Flutter 开发的新手。当我尝试在 android studio 中启动颤振应用程序时,它会同步,但是当我运行应用程序时会出现白色空白屏幕。在命令行中,我收到了下面提到的错误。

    Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
Malformed line in ndk source.properties: "### Android Tool: Source of this archive.".
Malformed line in ndk source.properties: "#Fri Jun 05 17:15:06 IST 2015".
Malformed line in ndk source.properties: "Archive.HostBits=64".
Malformed line in ndk source.properties: "Archive.HostOs=windows".
Malformed line in ndk source.properties: "Pkg.Desc=Android NDK".
Malformed line in ndk source.properties: "Pkg.License=To get started with the Android SDK, you must agree to the following terms and conditions.\n\nThis is the Android SDK License Agreement (the "License Agreement").\n\n1. Introduction\n\n1.1 The Android SDK (referred to in the License Agreement as the "SDK" and specifically including the Android system files, packaged APIs, and SDK library files and tools , if and when they are made available) is licensed to you subject to the terms of the License Agreement. The License Agreement forms a legally binding contract between you and Google in relation to your use of the SDK.\n\n1.2 "Android" means the Android software stack for devices, as made available under the Android Open Source Project, which is located at the following URL\: http\://source.android.com/, as updated from time to time.\n\n1.3 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.\n\n2. Accepting the License Agreement\n\n2.1 In order to use the SDK, you must first agree to the License Agreement. Malformed line in ndk source.properties: "Pkg.LicenseRef=android-sdk-license".
Malformed line in ndk source.properties: "Pkg.Revision=1".
Malformed line in ndk source.properties: "Pkg.SourceUrl=https\://dl.google.com/android/repository/repository-11.xml".
Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...
Syncing files to device Android SDK built for x86...
I/Choreographer( 7081): Skipped 53 frames!  The application may be doing too much work on its main thread.
D/EGL_emulation( 7081): eglMakeCurrent: 0xad5e4e00: ver 3 0 (tinfo 0xa2dbf960)
D/EGL_emulation( 7081): eglMakeCurrent: 0xad5e5820: ver 3 0 (tinfo 0xa5883310)

当我使用颤振医生 --android-license,

   D:\Projects\Flutter_Projects\FlutterUi\flutter_app>flutter doctor --android-licenses
Malformed line in ndk source.properties: "### Android Tool: Source of this archive.".
Malformed line in ndk source.properties: "#Fri Jun 05 17:15:06 IST 2015".
Malformed line in ndk source.properties: "Archive.HostBits=64".
Malformed line in ndk source.properties: "Archive.HostOs=windows".
Malformed line in ndk source.properties: "Pkg.Desc=Android NDK".
Malformed line in ndk source.properties: "Pkg.License=To get started with the Android SDK, you must agree to the following terms and conditions.
All SDK package licenses accepted.======] 100% Computing updates...

当我使用颤振医生 -v

 [√] Flutter (Channel master, v1.3.14-pre.64, on Microsoft Windows [Version 10.0.17763.379], locale en-US)
    • Flutter version 1.3.14-pre.64 at D:\FlutterMaster\flutter
    • Framework revision 2e637d8303 (51 minutes ago), 2019-03-23 13:20:41 -0400
    • Engine revision 9f878fcb3e
    • Dart version 2.2.1 (build 2.2.1-dev.2.0 None)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Users\MageshPandian\AppData\Local\Android\Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 33.4.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] VS Code, 64-bit edition (version 1.29.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    X Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

【问题讨论】:

你的颤振医生命令怎么说? @CopsOnRoad 我更新了我的代码。 @FilledStacks 显示与上述相同的错误并启动白屏应用程序 @CopsOnRoad。那是我们启动 Flutter 项目时的默认代码。我认为我的 android studio 颤振设置有问题 @MageshPandian 请运行flutter doctor 并在此处发布您的输出。 【参考方案1】:

检查您发布的日志,可能是由于跳帧导致模拟器运行缓慢,或者处理代码需要很长时间。我很好奇使用hot restart 运行应用程序是否会发生相同的行为,或者应用程序是否在物理设备上运行。

如果您仍然遇到问题,您可以提交问题单here,并附上最少的重现和复制行为的步骤。

【讨论】:

以上是关于Flutter 出现白屏问题的主要内容,如果未能解决你的问题,请参考以下文章

为啥我在构建 Flutter Web 时会出现白屏

Flutter中使用Column中白屏问题

Flutter 应用程序在启动时显示白屏几秒钟

Flutter 发布 APK 构建 - 间歇性白屏

FlutterFlutter 启动白屏问题 ( 问题描述 | 在 launch_background.xml 中设置启动过渡 UI )

Flutter 应用程序无法在真实的 iOS 设备上运行(白屏)