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

拜拜、爱过 提交于 2019-11-28 17:10:28

I have solved it by deleting the folder

c: \ users \ [myusername] \ .gradle \ caches \ 2.14.1

After reopening Android studio it was all fine

okay here's very lightweight solution with steps:

  • Ctrl+Alt+Shift+S or File->Project Structure

  • Select Project from left panel

  • Now check your Gradle Version at right panel

  • In my case my Gradle Version is 3.3

  • Navigate C:\Users\ashish\.gradle\caches and delete your Gradle Version - 3.3 named folder.

  • Now restart or open your project again from workspace.

Greetings...your problem is solved.

You must erase /.gradle folder from user directory, not from project, it`s a hidden directory, if you used linux-based system it is in /home/user/.gradle and press "alt"+"." to show hidden folders

Go into your local file project and search for the ".gradle" folder

Erase it and restart your IDE

In android studio, Click on the "Invalidate caches/Restart.." and confirm.

Deleting cache folder take long time because it have more than 200k files which is more than 3GB. There is quick view as Ashish mentioned.

I also faced this error in only one app.

Go through the step.

  1. In you project open gradle-wrapper.properties file. Which is located in Gradle Script in Android structure. As shown in below image.

  2. In that file check distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip. Here gradle version is 4.6.

3.So all cache for that project will be store in your C:\Users\Your PC Name or User Name\.gradle\caches\4.6. As shown in below image.

  1. Close your android studio and delete the 4.6 folder. After deletion open android studio.

That's all. It took mine 6 hours to figure out and deleting cache folder. So I decide to post this answer. So people will not waste same time.

dvaey

I had the same problem. And deleting the project's .gradle folder didn't fix the problem.

I solved the problem by deleting the C:\Users\<username>\.gradle folder and made studio refresh the entire gradle build. I found I had 4 different versions of gradle installed from my upgrade path.

Lettings Mall

All of these solutions did not work for me on Android Studio 2.1. What worked was me opening gradle-wrapper.properties in project folder and changing my gradle reference on the line below:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

This was changed to:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip

After which gradle upgraded and the app started working!

From File menu click on Invalidate Cache / Restart. And then Click on Invalidate and Restart. It will fix your problem.

Delete C:\Users\user\.gradle\caches folder and restart the project.

None of the above resolutions worked for my instance of this error. I had just started the project, so I really wasn't concerned about the loss of it. I completed the following:

  1. Selected "File\Close Project" and the project closed.
  2. The opening screen to create a new project came up.
  3. I deleted the project from the list just to have it not show in the list.
  4. Created a new project with a slightly different name.
  5. Ran the new project and it worked fine.
  1. Get into the .gradle folder in the root of the project.

  2. There, you might see a couple of versions. Pick the gradle version that you're using in the porject.

  3. cd into taskArtifacts folder.

  4. clear the cache.properties.lock file.

Finally, build the project. Hope that helps.

None of the above worked for me ....

You just need to go to File -> Project Structure or jus press Ctrl+Alt+Shift+S

and then on the top left click Project Make sure that your Android Plugin Version is the same as you Android Studio Version .. This should fix it

additionally

You can also create a new Project and check under Project view initially you'll be in Android .. change the view to ... Project - > gradle (Note .. not .gradle only gradle ) ->wrapper ->gradle-wrapper properties.. open this file and you can see the last line ie ..

distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

make sure you have the same gradle version in your old files as well

Check out this Youtube Video i made regarding this issue

https://youtu.be/-Ngn4YvbKtw

It doesn't work none of above all.

  1. Close the project.
  2. Remove from project list
  3. Re-import the project again. (If you have a whole source file of a project, you should clean previous project and extract the project again)
  4. Open intellij and click open the project.
  5. Select the extracted folder/ project folder.

It is done.

- Go into your local file project and search for the ".gradle" folder,(folder from user directory, not from project, it`s a hidden directory, if you used linux-based system it is in /home/user/.gradle and press "alt"+"." to show hidden folders,)

  • Erase it and restart your IDE

if this doesnt work then, All of these solutions did not work for me on Android Studio 2.1. What worked was me opening gradle-wrapper.properties in project folder and changing my gradle reference on the line below:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

This was changed to:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip

After which gradle upgraded and the app started working!

Open your previous project and open file>ProjectStructure>project check this gradle version,android plugin version of previous project and set it to your current project .and click invalidate/restart

For the persons who have this problem on <Android Studio 3.1.2>. After I got this problem, I done all solutions in this topic. But each of the solutions alone did not solve my problem. So I've combined some strategies.


  1. First I removed application from Android Studio Launcher List.
  2. Second I deleted all the content from .gradle (FOLDER FROM USER DIRECTORY).
  3. Third I import the project again (after sync i got the error again).
  4. Fourth while project is open I used <Invalidate Cache / Restart> option from FILE menu.

I hope this solution work for you too.

We successfully resolved this error.. Go to your project location in my case it was F:=> PROJECT NAME=> .gradle.. and we deleted the the .gradle file.. then restarted android studio and loaded the project again.. and this time the the gradle build successfully.

Removing the .gradle directory from the user directory is not enough. Make sure to delete the .gradle directory from the project directory as well. In fact I would start with the project and only if that isn't enough should you delete at the user level.

In my case, GRADLE_USER_HOME was not set due to a machine change. After re-setting this env variable, everything works fine again.

From File menu click on Invalidate Cache / Restart. And then Click on Invalidate and Restart. It will solve your problem :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!