Gradle error after updating to Android Studio 2.3
Asked Answered
W

12

10

The gradle build is failing with the message

 Error:Could not create parent directory for lock file C:\Program Files\Android\Android Studio\gradle\gradle-2.14.1\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv\gradle-2.14.1-all.zip.lck

This is my build.gradle(Project)

 // Top-level build file where you can add configuration options common to all sub-projects/modules.

 buildscript {
   repositories {
    jcenter()
}
    dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
 }

allprojects {
  repositories {
    jcenter()
  }
}

  task clean(type: Delete) {
    delete rootProject.buildDir
}

All projects show the same error after the update.

Weissberg answered 4/3, 2017 at 8:14 Comment(6)
Try deleting .gradle file https://mcmap.net/q/216572/-error-unexpected-lock-protocol-found-in-lock-file-expected-3-found-0 and restart studioMagdaleno
Tried that already. Same error. @sunilsunnyWeissberg
Tried invalidate caches/Restart option as well .?Magdaleno
Tried that same error.Weissberg
I am also facing similar issue, tried many solutions no luck.. have been 3 days.Doubletalk
Try this once, hope it will help you https://mcmap.net/q/194336/-gradle-version-3-3-does-not-support-fortask-method-on-buildactionexecuterEnchain
D
6

I was also facing the similar error, below changes did the job.

The issue was Android Studio 2,3 and it's default gradle version is 3.3.

I accidentally updated SDK build tools to latest one 25.0 .0, after Android Studio popped up message to update and Gradle plugin version to 2.3.0 for which required gradle version is 3.3+.

I did the below changes to fix the issue:

  1. Installed older SDK build tools 19.1.0 to use previous Gradle versions
  2. File> Project Structure > Project > And change the gradle version to 2.3.0
  3. Changed build.gradle(Project: app_name) > classpath 'com.android.tools.build:gradle:3.3.0' to 'com.android.tools.build:gradle:2.1.2'

Finally, do Invalidate Caches / Restart or Sync.

It seems like it's better not to use 3.3 yet. Source & Credits

Doubletalk answered 13/3, 2017 at 2:11 Comment(0)
L
3

Try to set in your build.gradle:

classpath 'com.android.tools.build:gradle:2.3.0'

In gradle-wrapper.properties:

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

And then check "Use default gradle wrapper (recommended)" in Android Studio settings (Gradle tab).

Sync project or invalidate cash and restart.

Leyden answered 5/3, 2017 at 2:31 Comment(0)
E
3

Step 1:changes in gradle-wrapper.proprties

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

Step 2:changes in app\build.gradle

 classpath 'com.android.tools.build:gradle:2.3.0'

Step 3: changes in project level build.gradle

classpath 'com.android.tools.build:gradle:2.3.0'

sync your project.
It solved my problem.
Eulogize answered 8/3, 2017 at 8:0 Comment(2)
Copy and paste this answer?:)Leyden
Its not copy and paste ,I have mentioned 3 steps that clearly mention which files you have to modify :) :)Eulogize
O
1

Just press in AndroidStudio:

Sync Project with Gradle Files.

Overbite answered 9/3, 2017 at 21:5 Comment(1)
@Jorgesys you try. For me this solution helped.Overbite
F
0

Hi i am also got the same problem. But now i got solution

First you should update Android NDK-bundle. This is under File--> Project Structure SDK Location last one. There is one option download.

After Again create new package with all plugins install again Then import the project. That time don't do update again. Then it was working me.

Try it All the best*****

Fuliginous answered 6/3, 2017 at 11:59 Comment(0)
T
0

I tried some of the other suggestions here, but ultimately after deleting my .gradle directory and setting everything up again it seemed to be OK

Tolan answered 19/3, 2017 at 20:39 Comment(0)
J
0

Android studio 2.3 and preview 2.4 requires Gradle version 3.3 & above!!! I had 2.8 it didn't work.
I installed 3.4 & it still didn't work, I figured out that the source directory
was set to 2.8, not 3.4!!
So make sure u have 3.3 or 3.4 installed and the path is set to the correct one... Even don't set the path to say
C:\user......\gardle\bin
set it to
C:\user.....\gradle
I had the problem for days!!!Wish it works well for you....

Jillianjillie answered 26/3, 2017 at 17:14 Comment(0)
M
0

I had the exact same problem. I debugged the issue by adding debug statements to \platforms\android\cordova\lib\check_reqs.js (90:25). From this debug I found that my previous SDK did have a templates directory - for my installation is is: C:\Android\SDK\tools\templates.

Fortunately I had a backup of that directory. So my final solution for Android 2.3.1 installation was to copy my C:\Android\SDK\tools\templates directory to the newly created SDK directory from the 2.3.1 installation.

I don't like this in-eligant solution but it did immediately resolve my problem.

I hope this helps someone.

Moonlit answered 10/4, 2017 at 20:51 Comment(0)
S
0

i had the same problem. this is how i solved mine:
1. Download gradle-4.0
2.Download NDK using SDK manager
3. open file>settings>Build,Execution,Deployment>gradle and configured as below. Click Here to view image

it solved my problem

Sememe answered 22/6, 2017 at 13:1 Comment(0)
F
0

Try my solution

I'm using android studio 2.3.1, i just make a few step to solved the problem.

based on doc at androiddev https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle

Plugin version Required Gradle version

  • 1.0.0 - 1.1.3 2.2.1 - 2.3
  • 1.2.0 - 1.3.1 2.2.1 - 2.9
  • 1.5.0 2.2.1 - 2.13
  • 2.0.0 - 2.1.2 2.10 - 2.13
  • 2.1.3 - 2.2.3 2.14.1+
  • 2.3.0+ 3.3+

Requirement : Gradle version 3.4

Step 1 Remove all gradle in folder C:\Users\.gradle\daemon

Step 2 Redownload Gradle 3.4 and put in directories C:\programfiles\android\androidstudio\gradle

step 3 Configure gradle in android studio 2.3.1 gradle settings. change to folder "C:\Program Files\Android\Android Studio\gradle\gradle-3.4"

Step 4 close your android studio and reopen project

I hope this solution help.

Fanfaron answered 31/8, 2017 at 7:11 Comment(0)
M
0
  1. Download it manually from https://gradle.org/releases/ .

  2. Extract it and make a dir for it in ur Android Studio And your SYSTEM.

  3. Android Studio: Setting > Build > Gradle > Uncheck Offline Work and put the DIR.

  4. System: Environment Variables > Edit(if u have another gradle PATH) or New > put The DIR.

Have a good day.

Merriweather answered 19/9, 2017 at 21:47 Comment(0)
I
-1

Just try to change this line like the below one distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip

and refresh it. If it still not works then there can be option which will automatically update your dependencies according to the version installed.

Ignitron answered 13/6, 2017 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.