Android Studio 迁移到新机器后构建Flutter项目的问题

mdfafbf1  于 2023-01-13  发布在  Android
关注(0)|答案(1)|浏览(168)

我最近不得不迁移到一个新的开发机器。我下载并安装了Android Studio和Flutter。在拉下我正在工作的项目后,我试图运行它。在编译过程中,我遇到了以下错误:

Running Gradle task 'assembleDebug'...
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-2.3.6/lib/src/structs.g.dart:661:31: Error: Member not found: 'UnicodeChar'.
  int get UnicodeChar => Char.UnicodeChar;
                              ^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-2.3.6/lib/src/structs.g.dart:662:38: Error: Setter not found: 'UnicodeChar'.
  set UnicodeChar(int value) => Char.UnicodeChar = value;
                                     ^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-2.3.6/lib/src/structs.g.dart:664:29: Error: Member not found: 'AsciiChar'.
  int get AsciiChar => Char.AsciiChar;
                            ^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-2.3.6/lib/src/structs.g.dart:665:36: Error: Setter not found: 'AsciiChar'.
  set AsciiChar(int value) => Char.AsciiChar = value;
                                   ^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_typeahead-3.2.4/lib/src/cupertino_flutter_typeahead.dart:746:9: Error: No named parameter with the name 'maxLengthEnforced'.
        maxLengthEnforced: widget.textFieldConfiguration.maxLengthEnforced,
        ^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/packages/flutter/lib/src/cupertino/text_field.dart:212:9: Context: Found this candidate, but the arguments don't match.
  const CupertinoTextField({
        ^^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_typeahead-3.2.4/lib/src/flutter_typeahead.dart:936:9: Error: No named parameter with the name 'maxLengthEnforced'.
        maxLengthEnforced: widget.textFieldConfiguration.maxLengthEnforced,
        ^^^^^^^^^^^^^^^^^
/C:/Flutter/flutter/packages/flutter/lib/src/material/text_field.dart:277:9: Context: Found this candidate, but the arguments don't match.
  const TextField({
        ^^^^^^^^^

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159

* What went wrong:
Execution failed for task ':app:compileFlutterBuildProdDebug'.
> Process 'command 'C:\Flutter\flutter\bin\flutter.bat'' 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.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
Exception: Gradle task assembleDebug failed with exit code 1

这看起来像是我的Flutter版本中的一个包丢失了。我已经尝试了修复缓存、删除构建文件和升级Flutter。我还没有找到解决方案。
编辑:我运行了flutter doctor -v,并让它运行到没有问题的地步。问题仍然存在。我仔细检查了项目和flutter路径,没有任何东西沿着了它。
编辑:我创建了一个测试Flutter项目,运行良好,所以这与这个项目具体有关。

hlswsv35

hlswsv351#

问题是我最初用Flutter的旧版本构建了这个项目,当我迁移到一台新机器上时,我安装了一个新版本,一些依赖项没有改变。
解决方案是升级构建错误中显示的包,以便它们可以与新版本的Flutter一起工作。

相关问题