错误:任务“:app:processDebugResources”的执行失败。> java.io.IOException: 无法在 android studio 中删除文件夹“”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35674066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error:Execution failed for task ':app:processDebugResources'. > java.io.IOException: Could not delete folder "" in android studio
提问by Ehsan Akbar
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:
我正在尝试使用 Android Studio 开发一个 Android 应用程序,因此我创建了一个 Android 应用程序并想发布它。每当我单击“构建项目”以获取 apk 文件时,都会收到此错误:
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
Build.gradle:
构建.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'
}
采纳答案by Henning Luther
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.
我猜目标构建目录中的某些文件是在您使用的另一个工具中打开的。只需在必须清理的文件夹中打开一个文件句柄。构建任务“clean”想要删除构建目录(通常是“target”)中的所有文件,当它失败时,构建就会失败。
回答by W00di
Just clean your project, it works for me.
只需清理您的项目,它对我有用。
Clean task for gradle will work.
gradle 的清理任务将起作用。
回答by Rob
REACT NATIVE
反应本机
From your react native folder run:
从您的本机文件夹运行:
cd android && gradlew clean
cd android && gradlew clean
THEN
然后
cd .. && react-native run-android
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;
andgradlew
to.\gradlew.bat
Each command can also be run individually like so
cd android
thengradlew clean
thencd ..
thenreact-native run-android
笔记:
对于 mac,您可能需要更改
gradlew
为./gradlew
对于命令提示符,您可能需要
&&
将&
对于 powershell,您可能需要更改
&&
to;
和gradlew
to.\gradlew.bat
每个命令也可以单独运行,就像
cd android
thengradlew clean
thencd ..
thenreact-native run-android
回答by Shivaramakrishna Agapu
Fix is very simple: Just follow below instructions
修复非常简单:只需按照以下说明进行操作
- First, save the project
- Click on project folder
- Click on Syncronize button in the menubar (The third icon from the left which is just below to File menu option)
- Clean project and run
- 一、保存项目
- 点击项目文件夹
- 单击菜单栏中的同步按钮(左起第三个图标,位于文件菜单选项的正下方)
- 清理项目并运行
回答by Moshe Edri
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
构建 -> 清理项目或构建 -> 重建项目
回答by oguzhan
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.
就我而言,该问题与权限有关。如果您以管理员身份(或使用sudo)打开android studio,那么如果您再次以普通用户身份打开项目,android studio 可能不会删除某些文件,因为当您以管理员身份打开项目时,某些项目文件的权限会发生变化。如果您经历了这些步骤,我认为您应该再次从您的 VCS(git、tfs、svn 等)克隆该项目。否则,您必须配置项目文件 - 文件夹权限。
回答by Farhan
I have same issue. When I clean my project and rebuild it then everything works fine.
我有同样的问题。当我清理我的项目并重建它时,一切正常。
Build -> Clean Project
构建 -> 清理项目
回答by Harry
Just clean your project (Android Studio>Build>Clean Project) and build again.
只需清理您的项目(Android Studio>Build>Clean Project)并再次构建。
回答by Umar Farooq Awan
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
- 将 ReactNativeApp/android/build 目录重命名为 old.build
- 关闭 Android Studio
- 在 ReactNativeApp/android 中执行了这个命令。渐变干净
- 确保我的 RAM 有 1500MB 可用空间
- 然后最后执行命令 react-native run-android
** It's quite interesting to close Android Studio. But beleive me these steps solved my problem **
** 关闭Android Studio 很有趣。但相信我这些步骤解决了我的问题**
回答by Qin Chao
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
我在这篇文章中找到了另一个方便的解决方案,它避免了一次又一次地重建所有组件:http: //bitstopixels.blogspot.ca/2017/04/react-native-windows-10-eperm-operation.html
- Execute
react-native run-android
- As soon as React Packager window opens, close it
- 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.) - Then run
react-native start
to start the React Packager, this is the server indicated in the error message of the previous step - Reload the app in emulator or device (Double tap the R key)
- 执行
react-native run-android
- React Packager 窗口一打开,关闭它
- 等待
react-native run-android
完成给您 BUILD SUCCESSFUL 消息。(该应用程序将启动并显示红色错误屏幕,抱怨连接到服务器失败。不要惊慌。) - 然后运行
react-native start
启动React Packager,这是上一步报错信息中指出的服务器 - 在模拟器或设备中重新加载应用程序(双击 R 键)