OS version: Ubuntu 14.04 LTE 64 Bit
操作系统版本:Ubuntu 14.04 LTE 64位
Java JRE/JDK version: Oracle JDK 1.8.0_11
Java JRE/JDK版本:Oracle JDK 1.8.0_11。
Project directory is on a NTFS based drive.
项目目录是基于NTFS的驱动器。
Whenever I try to clean my project I get something like below.
每当我尝试清理我的项目时,我会得到如下的东西。
:app:clean FAILED Error:Execution failed for task ':app:clean'.
:app:clean FAILED Error:Execution FAILED for task ':app:clean'。
Unable to delete file: /media/DriveA/AndroidStudioWorkspace/DNA/app/build/intermediates/classes/debug/.../mechandising/MerchandizingActivity$3.class
无法删除文件:/media/DriveA/AndroidStudioWorkspace/DNA/app/build/intermediates/中级/classes/debug/…/ machinery / merchanzingactivity $3.class
When I try to delete the build folder manually I get the following error.
当我尝试手动删除构建文件夹时,我得到以下错误。
Error when getting information for file '/media/DriveA/AndroidStudioWorkspace/DNA/app/build/intermediates/pre-dexed': Input/output error
在获取文件“/media/DriveA/AndroidStudioWorkspace/DNA/app/build/intermediates/pre-dexed”信息时出错:输入/输出错误
I am unable to figure out whether its a Linux problem or a Studio problem. I don't face such a problem in Eclipse (Same Drive) so I am just considering it to be something wrong with my studio.
我不知道这是Linux的问题还是Studio的问题。我在Eclipse中没有遇到这样的问题(相同的驱动器),所以我只是认为我的工作室有问题。
Any Suggestions??
有什么建议吗? ?
14 个解决方案
#1
33
I had the same problem.
我也有同样的问题。
You need to go to the source file directly. Close the studio and go to the path the issue is located at and delete the folder there.
您需要直接访问源文件。关闭studio并进入问题所在的路径,并删除该文件夹。
#2
15
Go to
去
File > Settings > Build, Execution, Deployment > Instant Run > Uncheck this Check box (Enable Instant Run to hot swap code)
文件>设置>构建、执行、部署
Thanks Have a nice coding
谢谢你写得很好
#3
9
You can go into the project directory and call gradle from the command-line to do a clean on the project:
您可以进入项目目录并从命令行调用gradle来清理项目:
gradlew clean
When you reopen the project you will need to run a gradle sync again.
当您重新打开项目时,您将需要再次运行一个gradle sync。
#4
4
Just ran into the same issue now - I accidentally edited one of the generated files and wanted to rebuild the app, but both clean
and build
failed due to some files being locked.
刚刚遇到了同样的问题——我不小心编辑了一个生成的文件,想要重新构建这个应用程序,但是由于一些文件被锁定,所以clean和build都失败了。
Luckily, I got cygwin
on my Windows machine, so ls -l <file that studio complained about>
revealed that these files were owned by some Administrator
dude.
幸运的是,我在Windows机器上安装了cygwin,所以studio抱怨>的ls -l
My first thought was that these files might had been created while Studio was running with admin privileges (I do this when I need to fetch updates from SDK manager
). The idea was to try and resolve this issue by executing clean
in Studio running with admin privileges, and later rebuild with normal privileges. Nope, this did not work :(
我的第一个想法是,这些文件可能是在Studio运行时创建的(当我需要从SDK管理器获取更新时,我会这样做)。这个想法是通过在运行管理权限的Studio中执行clean来尝试和解决这个问题,然后使用常规权限重新构建。不,这没用:(
I decided to go for the brute force: sudo rm -rf app/build/*
(in Cygwin
this command looks a bit different: cygstart --action=runas rm -rf app/build/*
). This resolved the issue and I was able to rebuild the project in Android Studio.
我决定使用蛮力:sudo rm -rf应用/build/*(在Cygwin中,这个命令看起来有点不同:cygstart -action=runas rm -rf应用/build/*)。这解决了这个问题,我能够在Android Studio中重建项目。
#5
#6
1
I had the same issue as you. I tried some of the solutions proposed on this page and it didn't work. So I used Process Explorer to find which process is locking the apk file and it was firefox. I think it keeps the file locked when I upload the apk in google play console. To make that go to "Find > Find Handle or DLL... > path-to-your-app.apk". Hope it help
我和你有同样的问题。我尝试了这个页面上提出的一些解决方案,但没有成功。所以我使用Process Explorer来查找哪个进程正在锁定apk文件,它是firefox。我想当我在谷歌播放控制台上传apk时,它会将文件锁定。点击“查找>查找句柄或DLL…”> path-to-your-app.apk”。希望它帮助
#7
1
On Linux this could happen if you have a locked
directories that prevents Android Studio from Deleting files.
在Linux上,如果您有一个锁定的目录,可以防止Android Studio删除文件,就会发生这种情况。
you can run the Following command on Terminal:
您可以在终端上运行以下命令:
sudo chown -R $USER: $HOME
Then try to rebuild --> Works for me
然后尝试重建——>适合我
#8
1
I stopped the windows defender it was locking the file because it was need to scan , and the problem resolved
我阻止了windows卫士它锁定文件,因为它需要扫描,问题解决了
#9
0
Go to your projects directory in the terminal and run gradlew clean
转到您的项目目录中的终端,运行gradlew clean
To run a Gradle command in your terminal/command prompt. Navigate to the root of your project and type gradlew
in the terminal or gradlew.bat
for the command prompt (windows users), followed by the command you would like to execute.
在终端/命令提示符中运行一个等级命令。导航到项目的根,并在终端或级别中键入gradlew。bat用于命令提示符(windows用户),然后是您想要执行的命令。
For a list of all possible gradle commands type gradlew tasks
into your terminal.
对于所有可能的gradle命令类型的列表,在您的终端中键入gradlew任务。
#10
0
I had a similar problem, when I was trying to debug my first android app. If you are running Android Studio on windows, I just restarted the Android studio and I did run Android Studio as Administrator which fixed the issue.
我也遇到过类似的问题,当我在调试我的第一个android应用程序时,如果你在windows上运行android Studio,我刚刚重启了android Studio,我作为管理员运行android Studio,解决了这个问题。
#11
0
I solved this issue by closing android studio -> remove android platform via cli and then -> add the android platform again -> open project in android studio.
我通过关闭android studio ->通过cli删除android平台,然后->再次添加android平台->开放项目在android studio中。
#12
0
I'm not on Windows, but OS X. Somehow my build folder didn't have the proper permission for AS to delete the file so I did chmod -R 777 <your_directory>
in the affected parent directory.. probably 777 isn't what you would want but it worked for me.
我不在Windows上,但是在OS x上。不知为什么我的构建文件夹没有适当的权限来删除文件,所以我在受影响的父目录中做了chmod -R 777
#13
0
Thanks to Gal's answer (https://*.com/a/39904628/2870404).
感谢Gal的回复(https://*.com/a/39904628/2870404)。
In windows, using Windows file explorer,
在windows中,使用windows文件资源管理器,
- right-click on the directory,
- 右键单击目录,
- click properties on the context menu that will appear,
- 单击将出现的上下文菜单上的属性,
- then uncheck the "Read Only" attribute.
- 然后取消“只读”属性。
- After that, click the "Apply" to apply changes.
- 然后,单击“Apply”应用更改。
#14
0
This fixed my problem.
这个固定我的问题。
Thanks to Gal's answer (https://*.com/a/39904628/2870404).
感谢Gal的回复(https://*.com/a/39904628/2870404)。
In windows, using Windows file explorer,
在windows中,使用windows文件资源管理器,
right-click on the directory, click properties on the context menu that will appear, then uncheck the "Read Only" attribute. After that, click the "Apply" to apply changes.
右键单击目录,单击将出现的上下文菜单上的属性,然后取消“只读”属性。然后,单击“Apply”应用更改。
#1
33
I had the same problem.
我也有同样的问题。
You need to go to the source file directly. Close the studio and go to the path the issue is located at and delete the folder there.
您需要直接访问源文件。关闭studio并进入问题所在的路径,并删除该文件夹。
#2
15
Go to
去
File > Settings > Build, Execution, Deployment > Instant Run > Uncheck this Check box (Enable Instant Run to hot swap code)
文件>设置>构建、执行、部署
Thanks Have a nice coding
谢谢你写得很好
#3
9
You can go into the project directory and call gradle from the command-line to do a clean on the project:
您可以进入项目目录并从命令行调用gradle来清理项目:
gradlew clean
When you reopen the project you will need to run a gradle sync again.
当您重新打开项目时,您将需要再次运行一个gradle sync。
#4
4
Just ran into the same issue now - I accidentally edited one of the generated files and wanted to rebuild the app, but both clean
and build
failed due to some files being locked.
刚刚遇到了同样的问题——我不小心编辑了一个生成的文件,想要重新构建这个应用程序,但是由于一些文件被锁定,所以clean和build都失败了。
Luckily, I got cygwin
on my Windows machine, so ls -l <file that studio complained about>
revealed that these files were owned by some Administrator
dude.
幸运的是,我在Windows机器上安装了cygwin,所以studio抱怨>的ls -l
My first thought was that these files might had been created while Studio was running with admin privileges (I do this when I need to fetch updates from SDK manager
). The idea was to try and resolve this issue by executing clean
in Studio running with admin privileges, and later rebuild with normal privileges. Nope, this did not work :(
我的第一个想法是,这些文件可能是在Studio运行时创建的(当我需要从SDK管理器获取更新时,我会这样做)。这个想法是通过在运行管理权限的Studio中执行clean来尝试和解决这个问题,然后使用常规权限重新构建。不,这没用:(
I decided to go for the brute force: sudo rm -rf app/build/*
(in Cygwin
this command looks a bit different: cygstart --action=runas rm -rf app/build/*
). This resolved the issue and I was able to rebuild the project in Android Studio.
我决定使用蛮力:sudo rm -rf应用/build/*(在Cygwin中,这个命令看起来有点不同:cygstart -action=runas rm -rf应用/build/*)。这解决了这个问题,我能够在Android Studio中重建项目。
#5
3
Clean project from Android Studio Terminal using this command 'gradlew clean'.
使用这个命令“gradlew Clean”从Android Studio终端清理项目。
#6
1
I had the same issue as you. I tried some of the solutions proposed on this page and it didn't work. So I used Process Explorer to find which process is locking the apk file and it was firefox. I think it keeps the file locked when I upload the apk in google play console. To make that go to "Find > Find Handle or DLL... > path-to-your-app.apk". Hope it help
我和你有同样的问题。我尝试了这个页面上提出的一些解决方案,但没有成功。所以我使用Process Explorer来查找哪个进程正在锁定apk文件,它是firefox。我想当我在谷歌播放控制台上传apk时,它会将文件锁定。点击“查找>查找句柄或DLL…”> path-to-your-app.apk”。希望它帮助
#7
1
On Linux this could happen if you have a locked
directories that prevents Android Studio from Deleting files.
在Linux上,如果您有一个锁定的目录,可以防止Android Studio删除文件,就会发生这种情况。
you can run the Following command on Terminal:
您可以在终端上运行以下命令:
sudo chown -R $USER: $HOME
Then try to rebuild --> Works for me
然后尝试重建——>适合我
#8
1
I stopped the windows defender it was locking the file because it was need to scan , and the problem resolved
我阻止了windows卫士它锁定文件,因为它需要扫描,问题解决了
#9
0
Go to your projects directory in the terminal and run gradlew clean
转到您的项目目录中的终端,运行gradlew clean
To run a Gradle command in your terminal/command prompt. Navigate to the root of your project and type gradlew
in the terminal or gradlew.bat
for the command prompt (windows users), followed by the command you would like to execute.
在终端/命令提示符中运行一个等级命令。导航到项目的根,并在终端或级别中键入gradlew。bat用于命令提示符(windows用户),然后是您想要执行的命令。
For a list of all possible gradle commands type gradlew tasks
into your terminal.
对于所有可能的gradle命令类型的列表,在您的终端中键入gradlew任务。
#10
0
I had a similar problem, when I was trying to debug my first android app. If you are running Android Studio on windows, I just restarted the Android studio and I did run Android Studio as Administrator which fixed the issue.
我也遇到过类似的问题,当我在调试我的第一个android应用程序时,如果你在windows上运行android Studio,我刚刚重启了android Studio,我作为管理员运行android Studio,解决了这个问题。
#11
0
I solved this issue by closing android studio -> remove android platform via cli and then -> add the android platform again -> open project in android studio.
我通过关闭android studio ->通过cli删除android平台,然后->再次添加android平台->开放项目在android studio中。
#12
0
I'm not on Windows, but OS X. Somehow my build folder didn't have the proper permission for AS to delete the file so I did chmod -R 777 <your_directory>
in the affected parent directory.. probably 777 isn't what you would want but it worked for me.
我不在Windows上,但是在OS x上。不知为什么我的构建文件夹没有适当的权限来删除文件,所以我在受影响的父目录中做了chmod -R 777
#13
0
Thanks to Gal's answer (https://*.com/a/39904628/2870404).
感谢Gal的回复(https://*.com/a/39904628/2870404)。
In windows, using Windows file explorer,
在windows中,使用windows文件资源管理器,
- right-click on the directory,
- 右键单击目录,
- click properties on the context menu that will appear,
- 单击将出现的上下文菜单上的属性,
- then uncheck the "Read Only" attribute.
- 然后取消“只读”属性。
- After that, click the "Apply" to apply changes.
- 然后,单击“Apply”应用更改。
#14
0
This fixed my problem.
这个固定我的问题。
Thanks to Gal's answer (https://*.com/a/39904628/2870404).
感谢Gal的回复(https://*.com/a/39904628/2870404)。
In windows, using Windows file explorer,
在windows中,使用windows文件资源管理器,
right-click on the directory, click properties on the context menu that will appear, then uncheck the "Read Only" attribute. After that, click the "Apply" to apply changes.
右键单击目录,单击将出现的上下文菜单上的属性,然后取消“只读”属性。然后,单击“Apply”应用更改。