Flutter 错误:无法从 /android/gradle/wrapper/gradle-wrapper.properties' 加载包装器属性

我是 Flutter 的新手,我刚刚观看了关于在 MacBook Pro 上设置 Flutter 的在线视频,我刚刚创建了我的第一个项目并尝试在我的系统连接到 Internet 时运行它,但出现了以下错误

Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
Exception in thread "main" java.lang.RuntimeException: Could not load wrapper properties from '/Users/bright/AndroidStudioProjects/second_flutterapp/android/gradle/wrapper/gradle-wrapper.properties'.
    at org.gradle.wrapper.WrapperExecutor.<init>(WrapperExecutor.java:64)
    at org.gradle.wrapper.WrapperExecutor.forWrapperPropertiesFile(WrapperExecutor.java:47)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:60)
Caused by: java.net.URISyntaxException: Illegal character in path at index 62: https://services.gradle.org/distributions/gradle-x.x.x-all.zip to gradle-6.7-all.zip
    at java.net.URI$Parser.fail(URI.java:2848)
    at java.net.URI$Parser.checkChars(URI.java:3021)
    at java.net.URI$Parser.parseHierarchical(URI.java:3105)
    at java.net.URI$Parser.parse(URI.java:3053)
    at java.net.URI.<init>(URI.java:588)
    at org.gradle.wrapper.WrapperExecutor.readDistroUrl(WrapperExecutor.java:81)
    at org.gradle.wrapper.WrapperExecutor.prepareDistributionUri(WrapperExecutor.java:70)
    at org.gradle.wrapper.WrapperExecutor.<init>(WrapperExecutor.java:57)
    ... 2 more
Exception: Gradle task assembleDebug failed with exit code 1

我在这里看到了很多这样的问题,但没有解决我的问题...我尝试删除“gradle-wrapper.jar”并替换“distributionUrl=https://services.gradle.org/distributions/gradle-x.x.x- all.zip 到 gradle-6.4.1-all.zip" 在 gradle-wrapper-properties 文件上并在我的终端上运行命令 "flutter run" 但仍然得到相同的错误

我试过“flutter医生”,它给了我下面的结果

Brights-MBP:~ bright$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.6 19G2021 darwin-x64,
    locale en-NG)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS
      development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install:
        sudo gem install cocoapods
[✓] Android Studio (version 4.1)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

我知道我还没有安装我稍后会安装的 Xcode,但我不确定这是否是问题#我做错了什么?

stack overflow Flutter error: Could not load wrapper properties from /android/gradle/wrapper/gradle-wrapper.properties'
原文答案

答案:

作者头像

看着路径,错误清楚地指出:

Caused by: java.net.URISyntaxException: Illegal character in path at index 62: https://services.gradle.org/distributions/gradle-x.x.x-all.zip to gradle-6.7-all.zip

**gradle-x.x.x-all.zip** 中检查文件 services.gradle.org/ distributions/ 时,在找到 **gradle-6.7-all.zip** 时不存在。因此,复制分布路径的错误可能是一个很大的因素。正确的文件应为 **gradle-6.7-all.zip**

另外,您已经提到这是您的MacOS中第一次设置Flutter。这样,您始终可以在任何错过的步骤/过程中查看有关 macOS install 的颤音文档的指南。