升级到v3.13后错误运行当前项目

时间:2020-08-06 09:54:05

标签: flutter dart

在Flutter升级v3.13之后,我在vscode调试控制台中得到以下错误运行项目:

Invalid depfile: C:\Users\DIMAS\FlutterCode\skip\.dart_tool\flutter_build\35269fa8986c9ee7a9c97697217003ec\kernel_snapshot.d
Invalid depfile: C:\Users\DIMAS\FlutterCode\skip\.dart_tool\flutter_build\35269fa8986c9ee7a9c97697217003ec\kernel_snapshot.d
Error: Could not resolve the package 'characters' in 'package:characters/characters.dart'.
/C:/src/flutter/packages/flutter/lib/src/material/text_field.dart:9:8: Error: Not found: 'package:characters/characters.dart'
import 'package:characters/characters.dart';
       ^
/C:/src/flutter/packages/flutter/lib/widgets.dart:18:1: Error: Not found: 'package:characters/characters.dart'
export 'package:characters/characters.dart';
^
/C:/src/flutter/packages/flutter/lib/src/rendering/editable.dart:10:8: Error: Not found: 'package:characters/characters.dart'
import 'package:characters/characters.dart';
       ^
/C:/src/flutter/packages/flutter/lib/src/services/text_formatter.dart:9:8: Error: Not found: 'package:characters/characters.dart'
import 'package:characters/characters.dart';
       ^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:26: Error: Type 'DiagnosticableMixin' not found.
class PictureStream with DiagnosticableMixin {
                         ^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:44: Error: Type 'DiagnosticableMixin' not found.
abstract class PictureStreamCompleter with DiagnosticableMixin {
                                           ^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:7: Error: The type 'DiagnosticableMixin' can't be mixed in.
class PictureStream with DiagnosticableMixin {
      ^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:16: Error: The type 'DiagnosticableMixin' can't be mixed in.
abstract class PictureStreamCompleter with DiagnosticableMixin {
               ^
/C:/src/flutter/packages/flutter/lib/src/material/text_field.dart:822:61: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
  int get _currentLength => _effectiveController.value.text.characters.length;
                                                            ^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/material/text_field.dart:824:118: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
  bool get _hasIntrinsicError => widget.maxLength != null && widget.maxLength > 0 && _effectiveController.value.text.characters.length > widget.maxLength;
                                                                                                                     ^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/rendering/editable.dart:244:64: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
       assert(obscuringCharacter != null && obscuringCharacter.characters.length == 1),
                                                               ^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/rendering/editable.dart:361:35: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
    assert(value != null && value.characters.length == 1);
                                  ^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/rendering/editable.dart:567:11: Error: 'Characters' isn't a type.
    final Characters remaining = string.characters.skipWhile((String currentString) {
          ^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/rendering/editable.dart:567:41: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
    final Characters remaining = string.characters.skipWhile((String currentString) {
                                        ^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/rendering/editable.dart:600:47: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
    for (final String currentString in string.characters) {
                                              ^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/rendering/editable.dart:602:40: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
          !_isWhitespace(currentString.characters.first.toString().codeUnitAt(0))) {
                                       ^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:167:11: Error: Superclass has no method named 'debugFillProperties'.
    super.debugFillProperties(properties);
          ^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:171:30: Error: The method 'toStringShort' isn't defined for the class 'PictureStreamCompleter'.
 - 'PictureStreamCompleter' is from 'package:flutter_svg/src/picture_stream.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart').
Try correcting the name to the name of an existing method, or defining a method named 'toStringShort'.
      ifPresent: _completer?.toStringShort(),
                             ^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:266:11: Error: Superclass has no method named 'debugFillProperties'.
    super.debugFillProperties(description);
          ^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/services/text_formatter.dart:355:11: Error: 'CharacterRange' isn't a type.
    final CharacterRange iterator = CharacterRange(value.text);
          ^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/services/text_formatter.dart:355:37: Error: Method not found: 'CharacterRange'.
    final CharacterRange iterator = CharacterRange(value.text);
                                    ^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/services/text_formatter.dart:356:20: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
    if (value.text.characters.length > maxLength) {
                   ^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/services/text_formatter.dart:375:61: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
    if (maxLength != null && maxLength > 0 && newValue.text.characters.length > maxLength) {
                                                            ^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/services/text_formatter.dart:378:25: Error: The getter 'characters' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'characters'.
      if (oldValue.text.characters.length == maxLength) {
                        ^^^^^^^^^^

Unhandled exception:
FileSystemException(uri=org-dartlang-untransla
table-uri:package%3Acharacters%2Fcharacters.dart; message=StandardFileSystem only supports file:* and data:* URIs)
[38;5;248m#0      StandardFileSystem.entityForUri  (package:front_end/src/api_prototype/standard_file_system.dart:33:7)[39;49m

[38;5;248m#1      asFileUri  (package:vm/kernel_front_end.dart:659:37)[39;49m
[38;5;248m#2      writeDepfile  (package:vm/kernel_front_end.dart:853:21)[39;49m
<asynchronous suspen
sion>
[38;5;248m#3      FrontendCompiler.compile  (package:frontend_server/frontend_server.dart:574:15)[39;49m
[38;5;244m<asynchronous suspension>[39;49m
#4      _FlutterFrontendCompiler.compile (packa
ge:flutter_frontend_server/server.dart:43:22)
[38;5;248m#5      starter  (package:flutter_frontend_server/server.dart:182:27)[39;49m

#6      main (file:///C:/b/s/w/ir/cache/builder/src/flut
ter/flutter_frontend_server/bin/starter.dart:9:30)
[38;5;244m#7      _startIsolate.<anonymous closure>  (dart:isolate-patch/isolate_patch.dart:299:32)[39;49m
#8      _RawReceivePortImpl
._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

失败:构建失败,并出现异常。

  • 其中: 脚本'C:\ src \ flutter \ packages \ flutter_tools \ gradle \ flutter.gradle'行:896

  • 出了什么问题: 任务':app:compileFlutterBuildDebug'的执行失败。

处理'命令'C:\ src \ flutter \ bin \ flutter.bat'结束时退出值非零

  • 尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行,以获取更多日志输出。使用--scan运行以获取完整的见解。

  • https://help.gradle.org

    获得更多帮助

57秒内失败 异常:Gradle任务assembleDebug失败,退出代码为1

它似乎缺少character.dart和一些gradle的东西,但是我现在在Google上找不到确切的问题和答案,

但是,如果我制作并运行一个新项目,则没有任何错误,我的pubspec.yaml(我将旧项目和新项目pubspec.yaml进行了比较,对于其他软件包,没有显着不同的说法): enter image description here

7 个答案:

答案 0 :(得分:17)

您似乎在pubspec.yaml中缺少字符包。

确保它在那里并且您的pubspec格式正确。然后再次运行flutter pub get

如果失败,则应运行flutter pub cache repair

答案 1 :(得分:6)

有同样的问题。

在pubspec.yaml中,只需执行flutter pub getflutter pub upgrade

然后在根目录终端中执行flutter clean,它将毫无问题地运行。

答案 2 :(得分:4)

在更新flutter SDK之后,我的flutter应用程序也遇到了类似的问题。

解决我的问题的方法是执行以下操作。

打开终端(CMD),导航至pubspec.yaml所在的flutter项目。运行以下命令:

解决方案

flutter pub get

flutter pub upgrade

在那之后,如果仍然有问题,可以运行flutter pub cache repair,但是

flutter clean

帮我解决了这个问题。

为了确定,我重新启动了Visual Studio和AVD虚拟设备 重新开始。

我使用哪些工具和软件:

Visual Studio代码1.47.3

Android Studio 4.0.1(Android虚拟设备)

Flutter 1.20.1(发布日期6.8.2020)

Dart 2.9.0

答案 3 :(得分:2)

刷新flutter pub get后,我遇到了SVG问题,并且将flutter_svg: ^0.17.4更新为flutter_svg: ^0.18.0,从而解决了SVG问题,

答案 4 :(得分:2)

在新的flutter版本上运行flutter upgrade后,我遇到了几次此问题。就我而言,解决方案与错误无关。只是过时的依赖关系。

我首先进行了flutter clean(来自Flutter> Flutter清理工具的IntelliJ / Android Studio。)

将我的pubspec.yaml依赖项更新到最新版本,并运行flutter pub upgrade

完成!现在您应该可以构建并运行

答案 5 :(得分:0)

在终端中尝试

$     flutter clean

之后

$     flutter doctor 

应该可以解决您的问题

答案 6 :(得分:0)

我遇到了同样的问题,在删除.dart_tool目录/文件夹并再次运行该应用程序之后,问题得以解决

相关问题