You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

新建Flutter项目运行报错:'dar'未识别及Gradle加载失败求助

Fix for Flutter Gradle Error: 'dar' not recognized & GradleWrapperMain ClassNotFound

Hey, let's troubleshoot this issue step by step! Looking at your error messages and project path (E:\Intern\26-light & dar theme\untitled1), the root cause is clear: your project directory contains spaces and an ampersand (&) character, which breaks Windows command line parsing. The command line is interpreting & dar as a separate command instead of part of the path, hence the 'dar' is not recognized error—this then prevents Gradle from loading its wrapper properly, leading to the ClassNotFoundException for org.gradle.wrapper.GradleWrapperMain.

Here are the fixes you can try, starting with the simplest and most effective one:

1. Move your project to a path without special characters/spaces

Windows command line struggles with paths that have spaces, &, #, or other special symbols. Do this:

  • Cut your Flutter project folder and paste it into a directory like E:\Intern\LightDarTheme\untitled1 (no spaces, no & or other special chars).
  • Close and reopen Android Studio, then open the project from the new path.
  • Try running the app again, or execute flutter run in the new project directory.

2. Regenerate the Gradle wrapper (if moving the project doesn't work)

If the path fix alone doesn't resolve the Gradle wrapper issue, try resetting the wrapper files:

  • Delete the android/gradle folder, plus the android/gradlew and android/gradlew.bat files from your project.
  • Open a terminal, navigate to your project's android directory:
    cd android
    
  • Generate a new Gradle wrapper (use a version compatible with your Flutter SDK—Flutter 3.x typically uses Gradle 7.x, adjust if needed):
    gradle wrapper --gradle-version 7.4
    
  • Go back to the project root and run flutter run again.

3. Verify your environment configurations

Double-check these to rule out any underlying setup issues:

  • Run flutter upgrade to make sure you're on the latest stable Flutter SDK.
  • Confirm that JAVA_HOME and GRADLE_HOME environment variables are set correctly, pointing to valid JDK and Gradle installations (no spaces in these paths either!).

内容的提问来源于stack exchange,提问作者Lakshan Kodithuwakku

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 10:10:31