Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
891 views
in Technique[技术] by (71.8m points)

compilation - Android Studio problem with compiling "The process cannot access the file because it is being used by another process."

I know this question has been asked before, but there wasn't a satisfactory answer, and the last post was three years ago. I am using android studio 3.6.2 in windows 10. Every time I try to compile my program I get the error "The process cannot access the file because it is being used by another process."

Now I know what is causing the error. The R.jar file that was previously compiled cannot be deleted because android studio is locking the file. It is in a folder appuildintermediatescompile_and_runtime_not_namespaced_r_class_jardebug

Now to get around the problem I have been closing down android studio. Then deleting the R.jar, then restarting android studio and then compiling. This process takes a good few minutes and I have to do it every time. Imagine how long it takes to write a program when you have to do this every time.

When this was asked on stack overflow previously suggestions were to Invalid caches / restart, but that is no quicker than what I did above, and only works once. Also tried Clean Project, but that has no effect.

I have used many compilers over the years like visual studio, codeblocks etc but this kind of thing never happened before, so why is android studio so bad? Has anyone found a solution to this problem yet?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

[Remove Build][Go to Edit Configurations]

Go to Edit Configurations check that you are not building before each launch. Remove "Build"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...