“Flutter Code extension not installed” but it'

2020-04-17 05:59发布

问题:

Have been using Flutter with VSCode on Mac for months without issues, but suddenly flutter doctor produces this:

[✓] 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.

I can confirm that flutter is installed, and nothing has changed since I started using it. Additionally, before I updated flutter (today), flutter doctor read, under VSCode, as:

[!] 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

However, post-upgrade that seems the inability to find dart might have been fixed.

There is a post from a few days ago here that indicates flutter doctor may just be inaccurate for the time being, so I tried to run the project, and got the following error stack:

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

Any thoughts on this?

回答1:

There was a change in VSCode that broke extensions detection. It's safe to ignore this warning.

See the full comment of Danny Tuppeny, about this issue here.

For the stacktrace there are two things:

  • The asset "ios/Flutter/flutter_assets/fonts/MyFlutterApp.ttf"was not found
  • The issue with obsvervatory

Did you check the asset still exists? The project does not compile without it, and the observatory issue may be related to this.



回答2:

Install the Flutter extension within VS Code.