【问题标题】:Finished with error: Gradle task assembleDebug failed with exit code 127 , when i run flutter for the first time完成错误:当我第一次运行颤振时,Gradle 任务 assembleDebug 失败,退出代码为 127
【发布时间】:2026-02-08 09:25:02
【问题描述】:

我在运行 Flutter 时遇到问题。一旦我运行颤振,它会在可视代码上显示以下错误,对此的任何解决方案。我跑flutter doctor,不知道是不是细节问题。

Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling
software rendering with "--enable-software-rendering".
Launching lib/main.dart on sdk gphone x86 in debug mode...
**env: bash\r: No such file or directory**                               
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                         2.9s
*Exception: Gradle task assembleDebug failed with exit code 127*```


Just in case you need the Flutter Doctor here is it:

```Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B50 darwin-x64, locale en-GB)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✗] 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.0)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.54.1)
[✓] Connected device (1 available)

! Doctor found issues in 2 categories.```

【问题讨论】:

    标签: android ios flutter visual-studio-code


    【解决方案1】:

    按照这一行的建议

    **env: bash\r: No such file or directory**
    

    您似乎已经下载了 Flutter 的 Windows 二进制文件,但您使用的是 macOS。您应该下载正确的二进制文件并重新安装 Flutter。在这里查看更多信息:https://github.com/flutter/flutter/issues/27076#issuecomment-487300955

    【讨论】:

      【解决方案2】:

      你在VS代码中下载了flutter和dart插件了吗? 完成本网站文章中提到的步骤后 https://giancarlocode.com/flutter-tutorials/how-to-install-flutter-on-windows-10-on-visual-studio-code-and-android-studio/

      【讨论】:

        最近更新 更多