'Unexpected lock protocol found in lock file. Expected 3 found 0

In android studio I keep getting this error message when building. I've tried deleting the .gradle file multiple times and restarting the IDE but the error doesn't seem to stop.

I made sure that I've updated EVERYTHING there is in SDK's and other things it required.



Solution 1:[1]

I've tried several solution -

First Solution: Go to File -> Invalid Chaches/Restart...

Second Solution: First, Build -> Clean Project and the Build -> Rebuild Project

Third Solution: First close the project and remove from workspace of Android Studio, then Go to C:\Users\user.gradle then delete .gradle folder. After that Open the project again.

But none of them worked! Then i got a solution, which worked in my case, the solution is bellow -

In my case, the problem was in gradle version. Check your Gradle version File -> Project Structure(Ctrl+Alt+Shift+S) and Plugin version also.

Solution 2:[2]

Delete the XXX.Lock file, and rerun the project. You should be able to find the location of this .lock file in the error message

Solution 3:[3]

is solved mine by downloading the latest version the latest version of gradle distribution.

https://services.gradle.org/distributions/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rakib Hasan
Solution 2 Jordy Voorham
Solution 3 Victor Chinyeaka