Failed to create parent directory

Hi,

I am facing an issue in my flutter code. I attempt to run it and debug console is throwing this error “Failed to create parent directory 'C:…”. Someone suggested to run flutter clean followed by flutter run. I did it and the app was up and running. However, the problem is that it only works from the terminal. If I try to run the app using the VS Code GUI (the button in the top right), the same error reappears. Even after running flutter clean and then clicking the debug button, the error still persists.

"Launching lib\main.dart on SM N975F in debug mode…

FAILURE: Build failed with an exception.

  • What went wrong:

Execution failed for task ‘:app:compileFlutterBuildDebug’.

Failed to create parent directory ‘C:\Users\Mujeeb’ when creating directory ‘C:\Users\Mujeeb\ Khawaja\Desktop\flutter\ projects\new\ videx\videx\build\app\intermediates\flutter\debug\flutter_assets’

  • 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 6s

Error: Gradle task assembleDebug failed with exit code 1"

My directory name in “This PC” is “C:\Users\Mujeeb Khawaja”, not ‘C:\Users\Mujeeb’ and flutter is trying to do “'C:\Users\Mujeeb\ Khawaja”.

Could someone please help?

Expected results

App up and running

Actual results

Launching lib\main.dart on SM N975F in debug mode…

FAILURE: Build failed with an exception.

  • What went wrong:

Execution failed for task ‘:app:compileFlutterBuildDebug’.

Failed to create parent directory ‘C:\Users\Mujeeb’ when creating directory ‘C:\Users\Mujeeb\ Khawaja\Desktop\flutter\ projects\new\ videx\videx\build\app\intermediates\flutter\debug\flutter_assets’

  • 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 6s

Error: Gradle task assembleDebug failed with exit code 1"

Edit: Ok, I deleted the folder “Build”, then run the project, it worked. But when I closed the project and run it again, the same issue appeared. My flutter version Flutter 3.32.5 • channel stable

it shouldn’t be a problem, but why do you a space there?

Probably a bug in the tool.

For Windows, spaces in names should have the entire path wrapped in quotes (so "C:\Users\Mujeeb Khawaja\Desktop").

In *nix OSes (Linux, Android, MacOS, etc.), a white space in path is escaped with \ (that’s what you are seeing in the logs, so, I believe, the tool is stupid and does not consider a 69% market share OS).

Flutter had this bug in the 1.xx versions, but it was fixed (so, it is not its fault, I guess). Since then, I always create my Windows user name as a single nickname (i.e.: no spaces).

And, no, Windows is not in fault here. It is just different.

No idea. I think maybe there is a problem with flutter. I upgraded it, maybe that is causing the issue. Also, one of my colleague suggested to change Android Studio version Koala to version meerkat, according to him, Koala doesn’t have proper integration with the latest flutter version.

Ok, I think I have solved the problem and found a solution.

Solution

Here’s what worked for me

:check_mark: 1. Install Android Studio Meerkat (2024.3.2 Patch 1)

  • Download from the official site:
    https://developer.android.com/studio

  • Version details:

    Android Studio Meerkat Feature Drop | 2024.3.2 Patch 1
    Build #AI-243.26053.27.2432.13536105, built on May 22, 2025
    

:green_circle: Meerkat might have updated tooling that resolves the path-handling issues introduced in newer Flutter versions.

:check_mark: 2. Reinstall the Android SDK via Android Studio

  • Go to Preferences > SDK Manager
  • Remove the old SDK (optional but recommended)
  • Re-download the latest stable Android SDK using Meerkat

:sparkles: Result

After doing the above:

  • :white_check_mark: No more need to delete the build/ folder
  • :white_check_mark: App runs both via terminal and VS Code GUI
  • :white_check_mark: Smooth build and debug experience
  • :white_check_mark: No Gradle-related parent directory errors

Takeaway

I was using Android Studio Koala which I think has poor integration with latest Flutter versions or any version, especially in Windows environments with spaced usernames or project paths.
Upgrading to Android Studio Meerkat and reinstalling the SDK completely solves the issue. It worked for me.


:sos_button: Still Seeing This?

If the issue persists even in Meerkat:

  • Ensure there’s no stale .gradle lock file
  • Run flutter clean