【问题标题】:flutter project build error when moved from one PC to other( window to mac)从一台 PC 移动到另一台 PC 时颤动项目构建错误(窗口到 mac)
【发布时间】:2020-03-07 07:20:39
【问题描述】:

我将颤振项目从窗口 PC 移动到 Mac。我正面临这个错误,我也尝试过flutter clean,但它不起作用。运行 flutter create 时出错。

    could not determine the dependencies of task app complieflutterbuilddebugarm flutter
java.net.URISytaxSException Illegal character in opaque part at index 2:c:\\User\\username\\Androidstudioprojects\\appname\\lib\\main.dart

当我在 windows pc 上创建简单的默认项目并将其移动到 mac 时,它工作正常,但我的大项目无法移动。

FAILURE: Build failed with an exception.

* Where:
Script '/Users/admin/Desktop/fluttersdk/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 875

* What went wrong:
Could not determine the dependencies of task ':app:compileFlutterBuildDebugArm'.
> java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\\Users\\Waqas\\AndroidStudioProjects\\Naija\\lib\\main.dart

* 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 45s
Finished with error: Gradle task assembleDebug failed with exit code 1

我在运行 flutter create 后得到了这个

admin@mac-mini Naija 2 % flutter create
Warning! The 'flutter' tool you are currently running is from a different Flutter repository than the one last used by this package. The repository from which the 'flutter' tool is
currently executing will be used instead.
  running Flutter tool: /Users/admin/Desktop/flutter
  previous reference  : /Users/admin/Desktop/fluttersdk/flutter
This can happen when you have multiple copies of flutter installed. Please check your system path to verify that you are running the expected version (run 'flutter --version' to see
which flutter is on your path).


No option specified for the output directory.
Create a new Flutter project.

If run on a project that already exists, this will repair the project, recreating any files that are missing.

Usage: flutter create <output directory>
-h, --help                     Print this usage information.
    --[no-]pub                 Whether to run "flutter pub get" after the project has been created.
                               (defaults to on)

    --[no-]offline             When "flutter pub get" is run by the create command, this indicates whether to run it in offline mode or not. In offline mode, it will need to have all
                               dependencies already available in the pub cache to succeed.

    --[no-]with-driver-test    Also add a flutter_driver dependency and generate a sample 'flutter drive' test.
-t, --template=<type>          Specify the type of project to create.

          [app]                (default) Generate a Flutter application.
          [package]            Generate a shareable Flutter project containing modular Dart code.
          [plugin]             Generate a shareable Flutter project containing an API in Dart code with a platform-specific implementation for Android, for iOS code, or for both.

-s, --sample=<id>              Specifies the Flutter code sample to use as the main.dart for an application. Implies --template=app. The value should be the sample ID of the desired
                               sample from the API documentation website (http://docs.flutter.dev). An example can be found at
                               https://master-api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html

    --list-samples=<path>      Specifies a JSON output file for a listing of Flutter code samples that can created with --sample.
    --[no-]overwrite           When performing operations, overwrite existing files.
    --description              The description to use for your new Flutter project. This string ends up in the pubspec.yaml file.
                               (defaults to "A new Flutter project.")

    --org                      The organization responsible for your new Flutter project, in reverse domain name notation. This string is used in Java package names and as prefix in the
                               iOS bundle identifier.
                               (defaults to "com.example")

    --project-name             The project name for this new Flutter project. This must be a valid dart package name.
-i, --ios-language             [objc, swift (default)]
-a, --android-language         [java, kotlin (default)]
    --[no-]androidx            Generate a project using the AndroidX support libraries

【问题讨论】:

  • 你清理你的项目了吗?
  • 是的,我做到了,但它对我不起作用。
  • “flutter --version”对两种环境的响应是否相同?

标签: gradle flutter dart


【解决方案1】:

删除.packages,在命令行中执行flutter pub get

【讨论】:

  • 谢谢兄弟,你的回答并没有为我节省了多少时间,实际上我将我的电脑从 Windows 7 升级到了 10,所以我也迁移了我的项目,但它采用了我的旧项目路径
【解决方案2】:

不要复制你的 .flutter-plugins 文件 并确保运行

flutter clean

flutter packages get

最后,如果上面没有提到的工作,你在同一个项目文件夹中尝试:

flutter create

【讨论】:

  • 我更新问题看看我在运行flutter create后得到了什么
  • 那更惨,我建议你新建一个项目并转移你的代码
  • 我有多个项目要处理,所以传输代码不会好,我需要有一个可靠的解决方案以避免将来出现此类问题
猜你喜欢
  • 2012-02-02
  • 1970-01-01
  • 1970-01-01
  • 2014-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多