Error:Execution failed for task ':app:processDebugResources'. > java.io.IOException: Could not delete folder "" in android studio

JavaAndroidAndroid Studio

Java Problem Overview


I am trying to develop a Android application using Android Studio, so I created an Android app and I want to publish it. Whenever I click on “build project“ to obtain the apk file, I get this error:

Error:Execution failed for task ':app:processDebugResources'.
> java.io.IOException: Could not delete folder C:\Users\ehsan\AndroidStudioProjects\MyApplication3\app\build\generated\source\r\debug\com\example\ehsan

Screenshot showing the error message

Build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.ehsan.myapplication"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
}

Java Solutions


Solution 1 - Java

REACT NATIVE

From your react native folder run:

cd android && gradlew clean

THEN

cd .. && react-native run-android

> Notes: > > For mac you may need to change gradlew to ./gradlew > > For the command prompt you may need to change the && to & > > For powershell you may need to change the && to ; and gradlew to .\gradlew.bat > > Each command can also be run individually like so cd android then gradlew clean then cd .. then react-native run-android

Solution 2 - Java

I guess some of the files in the target build directory is open in another tool you use. Just a file handle open in the folder which has to be cleaned. The build task 'clean' wants to delete all the files in the build directory(normally 'target') and when it fails, the build fails.

Solution 3 - Java

Just clean your project, it works for me.

Clean task for gradle will work.

Solution 4 - Java

Fix This issue by this command

In Windows Platform

cd android && gradlew clean && cd..

In Mac Platform

> cd android && ./gradlew clean && cd ..

Solution 5 - Java

Fix is very simple: Just follow below instructions

  1. First, save the project
  2. Click on project folder
  3. Click on Syncronize button in the menubar (The third icon from the left which is just below to File menu option)
  4. Clean project and run

Solution 6 - Java

as others have said allready you need to clean your project , the steps to clean the project are:

Build -> Clean Project or Build -> Rebuild Project

Solution 7 - Java

In my case, that problem is about permissions. if you open android studio as administrator (or using sudo) then if you open the project again as normal user, android studio may not delete some files because when you open the project as administrator, some project files permissions are changed. If you lived those steps, I think you should clone the project from your VCS (git, tfs, svn etc.) again. Otherwise you have to configure project file - folder permissions.

Solution 8 - Java

I have same issue. When I clean my project and rebuild it then everything works fine.

Build -> Clean Project

Solution 9 - Java

Just clean your project (Android Studio>Build>Clean Project) and build again.

Solution 10 - Java

I found another handy solution, which avoids rebuilding all components again and again, in this article: http://bitstopixels.blogspot.ca/2017/04/react-native-windows-10-eperm-operation.html

  1. Execute react-native run-android
  2. As soon as React Packager window opens, close it
  3. Wait for react-native run-android to complete giving you the BUILD SUCCESSFUL message. (The app will be launched with a red error screen complaining connecting to server failed. Don't panic.)
  4. Then run react-native start to start the React Packager, this is the server indicated in the error message of the previous step
  5. Reload the app in emulator or device (Double tap the R key)

Solution 11 - Java

If you encountered these errors due to opening the android studio with sudo command, then the solution is setting permission for the project folder. Run the command below.

sudo chmod -R 777 your_project_folder

clean and rebuild again your android project.

Solution 12 - Java

React Native

These steps solved my problem:

  • Renaming of ReactNativeApp/android/build directory to old.build
  • Closing Android Studio
  • Inside ReactNativeApp/android executed this command. gradlew clean
  • Making sure my RAM is 1500mb free
  • Then finally executing the command react-native run-android

** It's quite interesting to close Android Studio. But beleive me these steps solved my problem **

Solution 13 - Java

Stopping OpenSdk Java process (inner to Android Studio process) worked.

Solution 14 - Java

If you have another instance of Android Studio running, then kindly close it and then build the app. This worked in my case

Solution 15 - Java

If you are using macOS then => sudo ./gradlew clean will work for you.

Solution 16 - Java

I deleted folder app/build and the problem was resolved in my case.

Solution 17 - Java

Update your gradle version.

Go to your project level build.gradle file and make sure you are using the latest version of gradle.

Solution 18 - Java

React Native

In my case I just refresh ( http://localhost:8081/debugger-ui/ ) , and it works... Any other solutions didn't work for me. Perhaps some files are used by debuger and it can't delete them... Anyway, it works for me. Please try this and give a feedback.

Solution 19 - Java

If it says:

> The term 'gradlew' is not recognized

Then using following command

npm start -- --reset-cache

worked for me. cheers!

Solution 20 - Java

Delete android/app/build folder and run react-native run-android

Solution 21 - Java

From my experience in React Native, you can also restart your CLI and this error goes away.

Solution 22 - Java

I'm working on windows 10 and i can't find gradlew i cleaned the project using Android Studio : Build ---> clean project and after that i was able to run : react-native run-android or to run project using Android Studio

Solution 23 - Java

i just delete the error package from package.json and run again gradlew clean and its works for me For React Native

Solution 24 - Java

In my case it was that you had the app installed and when you gave it react-native run-android I could not install the app since it was already previously installed

Solution 25 - Java

Try closing your text editor (maybe VS Code) and File Explorer and run the command again in terminal with admin permissions.

Solution 26 - Java

Just Do onething File->Invalidate caches/ restart. After loading the project sync the project.enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEhsan AkbarView Question on Stackoverflow
Solution 1 - JavaRobView Answer on Stackoverflow
Solution 2 - JavaHenning LutherView Answer on Stackoverflow
Solution 3 - JavaW00diView Answer on Stackoverflow
Solution 4 - JavaAkash KumarView Answer on Stackoverflow
Solution 5 - JavaShivaramakrishna AgapuView Answer on Stackoverflow
Solution 6 - JavaMoshe EdriView Answer on Stackoverflow
Solution 7 - JavaoguzhanView Answer on Stackoverflow
Solution 8 - JavaFarhanView Answer on Stackoverflow
Solution 9 - JavaHarryView Answer on Stackoverflow
Solution 10 - JavaQin ChaoView Answer on Stackoverflow
Solution 11 - JavatngotranView Answer on Stackoverflow
Solution 12 - JavaUmar Farooq AwanView Answer on Stackoverflow
Solution 13 - JavaCícero MouraView Answer on Stackoverflow
Solution 14 - JavaAshwin BalaniView Answer on Stackoverflow
Solution 15 - JavaGanesh GaradView Answer on Stackoverflow
Solution 16 - Javabask0xffView Answer on Stackoverflow
Solution 17 - Javaartenson.art98View Answer on Stackoverflow
Solution 18 - JavakarolkarpView Answer on Stackoverflow
Solution 19 - JavaYashoda ChandrasekaraView Answer on Stackoverflow
Solution 20 - JavaRajesh NasitView Answer on Stackoverflow
Solution 21 - JavaVictor BurnettView Answer on Stackoverflow
Solution 22 - JavaKhaled BoussoffaraView Answer on Stackoverflow
Solution 23 - JavaarslanView Answer on Stackoverflow
Solution 24 - JavaFernando RoperoView Answer on Stackoverflow
Solution 25 - JavaCubeDevView Answer on Stackoverflow
Solution 26 - Javanagaraja TView Answer on Stackoverflow