我正在尝试使用带有 Dart Code/Flutter extension 的 Visual Studio Code 在物理 Android 设备上运行 Flutter 应用程序(曾经有效)。
但是当我尝试启动该应用程序时,它停留在 Installing build\app\outputs\apk\app.apk...
并且我的手机出现白屏。
我知道这个话题已经有很多话题了 1 2 3 ,但建议的解决方案对我不起作用,包括:
- 重启手机和电脑
- 卸载应用
flutter clean
- 使用
flutter build
构建应用程序,手动安装app-debug.apk
* 然后再次从 VS Code 启动应用程序 - 使用
adb uninstall
卸载应用程序并使用adb install
安装app.apk
- 卸载前从应用设置中清除缓存和存储
- 撤销USB调试权限
- 在我的手机上禁用 Play Protect
- 在手机的开发者选项中增加记录器缓冲区大小
*在我自己安装APK文件后,应用程序可以运行,当然我没有调试能力
当我在终端中执行 flutter run
时,该应用程序会在我的手机上打开并且运行良好。然而,热重载不起作用,只打印出以下内容:
$ flutter run -d FA685YJ01209
Launching lib/main.dart on HTC One M9 in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 4.0s
✓ Built build/app/outputs/apk/debug/app-debug.apk.
也无法从 Visual Studio Code 附加到该进程。
我还尝试使用 Visual Studio Code 在模拟器上启动应用程序。在这种情况下,它会卡在 Syncing files to device Android SDK built for x86...
。
$ flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Linux, locale en_US.UTF-8)
• Flutter version 1.12.13+hotfix.8 at /opt/flutter
• Framework revision 0b8abb4724 (7 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /home/scriptim/Dev/Android/SDK/
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.3
• Java binary at: /opt/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[!] Android Studio (version 3.6)
• Android Studio at /opt/android-studio
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (1 available)
• HTC One M9 • FA685YJ01209 • android-arm64 • Android 7.0 (API 24)
! Doctor found issues in 1 category.
最佳答案
显然 stable branch 上有变化解决了这个问题。 git pull
之后一切正常。不幸的是,我无法弄清楚问题到底出在哪里。
关于android - 如果通过 VS Code 运行,Flutter 运行卡在 "Installing build\...\app.apk",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60980852/