You don't have to delete all .gradle
folders and no need to reinstall Android Studio.
I have the latest version of Android Studio and I faced that problem, the only thing that worked for me is to:
Navigate to C:Usersuser.gradlecaches2.x
Copy the folder scripts , scripts-remapped and paste it somewhere safe just in case anything went wrong you will place it back
Delete this folder scripts and scripts-remapped from the directory C:Usersuser.gradlecaches2.x
Sync Project with Gradle Files and you are done.
When you sync your project Android Studio will generate new cache files.
You also need to delete buildOutputCleanup.lock from projectLocation/.gradle/buildOutputCleanup in case the above 4 steps do not work out.
It worked for me I hope it will work for you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…