如何修复“无法快照生成脚本”

时间:2019-09-12 10:37:54

标签: flutter dart

我为Web和Dart SDK安装了Flutter。添加到路径bin文件夹。跑了flutter pub global activate webdevflutter pub upgrade,但是输入webdev serve后我总是报错”:

[SEVERE] Failed to snapshot build script .dart_tool/build/entrypoint/build.dart.
[SEVERE] This is likely caused by a misconfigured builder definition.
[SEVERE] /C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.16/lib/src/protobuf/builder_info.dart:43:34: Error: Method not found: 'MapFieldInfo.map'.    _addField(MapFieldInfo<K, V>.map(name, tagNumber, index, PbFieldType.M,                                 ^^^/C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.16/lib/src/protobuf/field_info.dart:45:9: Error: '_mapEntryBuilderInfo' isn't an instance field of this class.        _mapEntryBuilderInfo = null {        ^^^^^^^^^^^^^^^^^^^^/C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.16/lib/src/protobuf/field_info.dart:61:9: Error: '_mapEntryBuilderInfo' isn't an instance field of this class.        _mapEntryBuilderInfo = null;        ^^^^^^^^^^^^^^^^^^^^/C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.16/lib/src/protobuf/field_info.dart:68:9: Error: '_mapEntryBuilderInfo' isn't an instance field of this class.        _mapEntryBuilderInfo = null {        ^^^^^^^^^^^^^^^^^^^^/C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.16/lib/src/protobuf/field_info.dart:82:12: Error: '_mapEntryBuilderInfo' isn't an instance field of this class.      this._mapEntryBuilderInfo])           ^^^^^^^^^^^^^^^^^^^^/C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.16/lib/src/protobuf/field_info.dart:199:9: Error: Superclass has no constructor named 'FieldInfo._'.      : super._(        ^^^^^/C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.16/lib/src/protobuf/field_info.dart:195:21: Error: Final field '_mapEntryBuilderInfo' is not initialized.Try to#7      _CommandRunner.runCommand (package:webdev/src/webdev_command_runner.dart:38:24)
<asynchronous suspension>
#8      CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#9      new Future.sync (dart:async/future.dart:224:31)
#10     CommandRunner.run (package:args/command_runner.dart:112:14)
#11     run (package:webdev/src/webdev_command_runner.dart:19:56)
#12     main (file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/webdev-2.5.1/bin/webdev.dart:17:22)
<asynchronous suspension>
#13     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:303:32)
#14     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

颤抖的医生:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.9.1+hotfix.2, on Microsoft Windows [Version 10.0.18362.356], locale ru-RU)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
      You may also want to add it to your PATH environment variable.

[!] Android Studio (not installed)
[√] VS Code (version 1.38.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.

pubspec.yaml:

name: addd
description: An app built using Flutter for web

environment:
  # You must be using Flutter >=1.5.0 or Dart >=2.3.0
  sdk: '>=2.3.0 <3.0.0'

dependencies:
  flutter_web: any
  flutter_web_ui: any

dev_dependencies:
  build_runner: ^1.5.0
  build_web_compilers: ^2.1.0
  pedantic: ^1.7.0

dependency_overrides:
  flutter_web:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages/flutter_web
  flutter_web_ui:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages/flutter_web_ui

该如何解决?

UPD。添加了更多详细信息(Flutter Doctor和pubspec.yaml)

3 个答案:

答案 0 :(得分:2)

嗨,我今天也遇到了同样的问题。幸运的是,与正常工作的版本相比,我发现它被protobuf版本> 0.13.15破坏了。

短期修复:

pubspec.yaml下的依赖关系下,将protobuf的版本降级为0.13.15:

dependencies:
  protobuf: <=0.13.15

先运行pub get,然后再运行webdev serve

答案 1 :(得分:1)

我也遇到了同样的问题,但是经过一些研究,我发现问题在于protobuf版本已过时,请尝试使用pubspec.yaml中的最新版本0.14.1

  dependencies:
  protobuf: <=0.14.1

您可以检查最新版本from here

答案 2 :(得分:0)

我昨天安装了扑扑环境,它工作正常。今天,我试图再次启动该项目,并得到相同的错误。

颤抖的医生

 Doctor summary (to see all details, run flutter doctor -v):
 [√] Flutter (Channel stable, v1.9.1+hotfix.2, on Microsoft Windows [Version 
 10.0.18362.356], locale en-US)
 [X] Android toolchain - develop for Android devices
     X Unable to locate Android SDK.
       Install Android Studio from: https://developer.android.com/studio/index.html
       On first launch it will assist you in installing the Android SDK components.
       (or visit https://flutter.dev/setup/#android-setup for detailed instructions).
       If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
       You may also want to add it to your PATH environment variable. 

 [!] Android Studio (not installed)
 [!] IntelliJ IDEA Community Edition (version 2019.2)
     X Flutter plugin not installed; this adds Flutter specific functionality.
     X Dart plugin not installed; this adds Dart specific functionality.
 [√] VS Code, 64-bit edition (version 1.38.0)
 [!] Connected device
     ! No devices available

 ! Doctor found issues in 4 categories.

pubspec.yaml

 name: demo
 description: An app built using Flutter for web

 environment:
   # You must be using Flutter >=1.5.0 or Dart >=2.3.0
   sdk: '>=2.3.0 <3.0.0'

 dependencies:
   flutter_web: any
   flutter_web_ui: any

 dev_dependencies:
   build_runner: ^1.5.0
   build_web_compilers: ^2.1.0
   pedantic: ^1.7.0

 dependency_overrides:
   flutter_web:
     git:
       url: https://github.com/flutter/flutter_web
       path: packages/flutter_web
   flutter_web_ui:
     git:
       url: https://github.com/flutter/flutter_web
       path: packages/flutter_web_ui