几个月来一直在 Mac 上使用 Flutter 和 VSCode 没有问题,但突然 flutter doctor 产生了这个:
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.4 17E202, locale en-US)
• Flutter version 0.5.1 at [Path]/flutter
• Framework revision c7ea3ca377 (3 weeks ago), 2018-05-29 21:07:33 +0200
• Engine revision 1ed25ca7b7
• Dart version 2.0.0-dev.58.0.flutter-f981f09760
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at [Path]/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.3.1, Build version 9E501
• ios-deploy 1.9.2
• CocoaPods version 1.5.2
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 25.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[!] VS Code (version 1.24.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected devices (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
! Doctor found issues in 1 category.
我可以确认安装了flutter,自从我开始使用它以来没有任何变化。此外,在我更新 flutter (今天)之前, flutter 医生在 VSCode 下阅读了以下内容:
[!] VS Code (version 1.24.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Dart Code extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code
但是,似乎无法找到 dart 的升级后可能已得到修复。
前几天有一个帖子 here 指出 flutter doctor 可能暂时不准确,所以我尝试运行该项目,并得到以下错误堆栈:
Using hardware rendering with device Android SDK built for x86.
If you get graphics artifacts, consider enablingsoftware rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... 2.0s
Resolving dependencies... 2.2s
Running 'gradlew assembleDebug'...
Error: unable to locate asset entry in pubspec.yaml:
"ios/Flutter/flutter_assets/fonts/MyFlutterApp.ttf".
Error building assets
FAILURE: Build failed with an exception.
* Where:
Script
'[Path]/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 435
* What went wrong:
Execution failed for task ':app:flutterBuildDebug'.
> Process 'command
'[Path]/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 17s
Gradle build failed: 1
MacBook-Pro-3:rambleapp TrentKennelly$ flutter trace
Error connecting to observatory: Exception: Attempted to connect to Dart
observatory 5 times, and all attempts failed. Giving up. The URL was
ws://127.0.0.1:8100/ws
对此有何想法?
最佳答案
VSCode 中的更改破坏了扩展检测。忽略此警告是安全的。
请参阅 Danny Tuppeny 关于此问题的完整评论 here 。
对于堆栈跟踪,有两件事:
"ios/Flutter/flutter_assets/fonts/MyFlutterApp.ttf"
是未找到
您是否检查过 Assets 仍然存在?
没有它项目就无法编译,天文台问题可能与此有关。
关于visual-studio-code - "Flutter Code extension not installed"但它已经安装了几个月,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50995661/