问题
Background: I've been fighting with Studio/Gradle for a day or so at this point; there were initially multiple PEBKAC errors (namely permissions and resource limits) that have since been resolved. Unfortunately the google-fu has failed me for this current error.
The error specifically occurred attempting to complete ./gradlew clean which did not complete successfully; it failed about 30s in.
I temporarily 'fixed' the problem by blowing away the offending git repo and cloning it anew. I discovered the error seems to occur only on a specific branch (ie, switch to x_branch, run 'clean project,' receive error), but have not yet figured out why. Attempting to switch to another branch or back to master after receiving the error does not revert gradle back to a working state; the error remains.
Error:
Gradle project refresh failed: Error: Already finished
System env: Android Studio 3.1 // Gradle version 171.4250
My question(s): Has anyone seen this error before? What does this error mean and how do I prevent it from re-occurring?
回答1:
Restarting Android studio :
File > Invalidate Caches/Restart worked for me
回答2:
This is what happen with me.
One of the folder (build folder) can't be access. I can't even open it using Windows Explorer. It looks like the folder has been corrupted.
I did the following:
- Clean the project: Build | Clean Project
- You will see problematic folder
- Close Android Studio
- Delete the folder
- Rebuild again
Good luck! I hope this solution help someone.
UPDATE
After deleting the folder, you may want to Invalidate Caches / Restart... I just hit on the same problem again. Deleting folder without Invalidate Caches / Restart... doesn't work :(
回答3:
I had this problem in my Android Studio, I managed to solve it by going to the folder where the android studio is installed and deleting the folder gradle when you return to your project to recompile and it will do the download again. I do not know if it's the best solution, but it works!
来源:https://stackoverflow.com/questions/47600021/gradle-project-refresh-failed-already-finished