'Flutter failed to create parent directory

I formatted my PC and kept flutter sdk location in the same spot. The only difference was the name of the user folder. Before it was called "thesl", but now it's "bscho". Whenever I go to build my flutter application, I get this:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Failed to create parent directory 'C:\Users\thesl' when creating directory 'C:\Users\thesl\OneDrive\dev\redlino\redlino\android\app\build\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 1s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

The path of my Flutter SDK is: C:\dev\flutter

The path of my Flutter app (where the pubspec.yaml is located) is: C:\dev\redlino\redlino (yes the two redlino's are there on purpose)

It also doesn't help that my project files used to be in OneDrive which I have since uninstalled.



Solution 1:[1]

I fixed my problem by deleting the build folder in the android/app directory.

Solution 2:[2]

In android/app there is build.gradle. Try delete it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Benjamin
Solution 2 richardec