Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle error after updating to Android Studio 2.3

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.

like image 700
Aditya Desai Avatar asked Mar 04 '17 08:03

Aditya Desai


People also ask

Why is my Gradle sync failing?

Using the Proxy Servers: There was an issue with the syncing of the Gradle when Proxy Servers were turned on. Disabling it can help. Cache Memory: Android Studio uses Cache memory for fast and smooth usage of the app. Sometimes the cache gets corrupted due to which Gradle sync fails.

How do I sync Gradle with Android Studio?

Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.


1 Answers

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

like image 140
Shankar Avatar answered Sep 29 '22 11:09

Shankar