Flutter: Execution failed for task ‘:app:packageDebug’

Error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageDebug'.
> java.io.IOException: Unable to delete directory 'C:\Users\dharm\AndroidStudioProjects\my_hospital_now\build\app\outputs\apk\debug'
    Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
    - C:\Users\dharm\AndroidStudioProjects\my_hospital_now\build\app\outputs\apk\debug\app-debug.apk

* 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 31s
Exception: Gradle task assembleDebug failed with exit code 1

Solution

Run this command for your project

run flutter clean

And run this command for your project

flutter pub get

Solution 2

Add Multidex

Solution 2

add Multidex

android {
defaultConfig {
    ...
    minSdkVersion 15 
    targetSdkVersion 28
    multiDexEnabled true
}
...


dependencies {
   implementation "androidx.multidex:multidex:2.0.1"
}

Solution 3

delete ~/.android/debug.keystore in Android SDK.

Note: Follow step-wise, only try Solution 3 if the above two do work.

Reference here:

Click here

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x