blackHawk
blackHawk

Reputation: 6307

After update android studio could not create parent directory for lock file

Updated android studio and plugins when sync, fails with could not create parent directory for lock file

wrapper properties:

#Sun Mar 05 16:51:59 PKT 2017 distributionBase=
GRADLE_USER_HOME  distributionPath=wrapper/
dists  zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/
dists  distributionUrl=https\://services.gradle.org/distributions/
gradle- 3.3-all.zip

build.gradle app module:

apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.sarahn.toyapplication"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-   rules.pro'
}
}
productFlavors {
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:
2.2.2',   {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
}

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.3.0'

// 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
}

tried downloading NDK, deleting .gradle folder from project and from installs but not going forward

Environment: Windows 10

Upvotes: 7

Views: 27435

Answers (7)

Akshitha
Akshitha

Reputation: 151

Verify the Gradle User Home path in the Android studio:

File -> Settings -> Build,Execution,Deployment -> Build Tools -> Gradle

Keep the Gradle User Home Empty.

Image for Settings in Android Studio

Upvotes: 15

JayMan89
JayMan89

Reputation: 31

This worked for me Android Studio v3.0

delete in the root folder .gradlew gradle.bat(on windows) , gradle/ .idea/ reopen the project.

Upvotes: -1

Obaida Alhassan
Obaida Alhassan

Reputation: 601

this worked for me android studio version 3.3.1

Click on File in the app bar then Invalidate caches / Restart then INVALIDATE AND RESTART

Upvotes: 0

Abubakr Mahdi
Abubakr Mahdi

Reputation: 1

Just go to gradle folder inside your android studio path and change the version of your gradle, by dowloading the latest gradle version. then go to android studio > settings and change gradle version to the one that you installed

Upvotes: 0

divix
divix

Reputation: 1364

For my case, (Win 10 64bits and Android Studio 3.1.3 I had to run the Android Studio as Administrator in order to fix the error.

Upvotes: 0

Alex Minjun Yu
Alex Minjun Yu

Reputation: 3707

In case someone has the same issue with Intellij on Ubuntu, the following solved my issue:

Remove everything in ~/.gradle/caches

Upvotes: 4

blackHawk
blackHawk

Reputation: 6307

I went to that location where gradle build failed to create parent directory and deleted cache folder there

Upvotes: 1

Related Questions