Android Studio:R.jar:进程无法访问该文件,因为它正被另一个进程使用 [英] Android Studio: R.jar: The process cannot access the file because it is being used by another process
问题描述
全新安装 Android Studio 3.6.3(便携式)后.当我尝试构建和运行我的项目时,我不断收到
After a new installation of Android Studio 3.6.3 (portable). When I try to build and run my project, I keep getting
app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug\R.jar:该进程无法访问该文件,因为它正在被另一个使用过程.
app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug\R.jar: The process cannot access the file because it is being used by another process.
不确定它想从我这里得到什么.我以管理员身份"运行 Android Studio,甚至关闭项目并重新打开它,第一次运行时,第二次出现错误.
Not sure what it wants from me. I run Android Studio "as administrator" and even closing the project and reopening it, the first time it runs, the second time I get the error.
我尝试使缓存无效并重新启动,我尝试删除 app/build 下的文件夹,但它似乎又回来了.我错过了什么?
I tried invalidate caches and restart, I tried deleting folders under app/build but it seems to come back. What am I missing?
谢谢
更新:
尝试清理项目时,我得到以下信息
When trying to clean the project, I get the following
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:clean'.
> Unable to delete directory 'C:\Users\name\Downloads\portable\android-studio\projects\appm\app\build'
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\name\Downloads\portable\android-studio\projects\appm\app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug\R.jar
- C:\Users\name\Downloads\portable\android-studio\projects\appm\app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug
- C:\Users\name\Downloads\portable\android-studio\projects\appm\app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar
- C:\Users\name\Downloads\portable\android-studio\projects\appm\app\build\intermediates
如果我等了几分钟,例如更新这个问题所花费的时间,那么它又可以工作了...
If I wait for several minutes, for example, the time it took me to update this question, then it works again...
更新:更新到 Android Studio 4 也出现同样的问题.
update: Updated to Android Studio 4 and the same problem occurs.
推荐答案
尝试
taskkill /im java.exe /f
在 cmd (Windows 10) 中
in cmd (windows 10)
这篇关于Android Studio:R.jar:进程无法访问该文件,因为它正被另一个进程使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!