Error:Unexpected lock protocol found in lock file.

2019-02-22 06:28发布

I updated my android studio into 2.3 then upon connecting my app to Firebase, it gave me an error:

Error:Unexpected lock protocol found in lock file. Expected 3, found 0.

Do I need to go back to 2.2.3 or is there any way to fix this? I tried deleting .gradle file in my project but it still gave me an error.

3条回答
可以哭但决不认输i
2楼-- · 2019-02-22 07:00

Before you go deleting you entire general .gradle folder for android studio, please note the following implications and consequences.

  • It will cost as much as 3 -4 GB to re-download its content
  • The download could take days if you are not careful and the network is not super fast
  • For every old project you reopen, chances are some items are missing therefore android studio will have to redownload missing content, god help you if chose to take out your laptop at a random eatery without free internet and quickly get some work done.
  • The deletion process involves thousands of file, up to 119k, the operating system finding them will take forever and deletion will take even longer.

Here is much better solution;

  • Close android studio completely
  • Using the file explorer of the operating system, in your app's project folder open the .gradle folder
  • Note the number(name) of the folder in it, such as (2.3 or 4.4 or 4.6 or 4.8)
  • Go to your general .gradle folder as described by @Gabriele Mariotti
  • open it and open the "caches" folder
  • Delete the folder with the same number as the second step
  • If you are paranoid like me you could also delete your project's .gradle file too (not necessary)

The file is not larger than 4 MB and it will not be re-downloaded but regenerated by android studio automatically, therefore the whole process should not take you 5 mins, costs no data, and all previous projects function as normal.

查看更多
Juvenile、少年°
3楼-- · 2019-02-22 07:03

Delete the .gradle folder from the project's root folder. For example if your project root folder is MyApp.

  1. Close your project in Android studio
  2. Remove your project from project list.
  3. Exit from android studio.
  4. Go to the MyApp Folder.
  5. Find the .gradle folder.
  6. Delete it.
  7. Restart Android Studio.
  8. Import your Project again.

Android Studio will download again all necessary Gradle files automatically (Internet Required).

All Done.

查看更多
4楼-- · 2019-02-22 07:23

Delete the .gradle folder from user directory, not from the project.

C:\users\username\.gradle in windows
/home/username/.gradle in Linux 
/users/username/.gradle in Mac
查看更多
登录 后发表回答