Gradle sync failed: Base: GRADLE_USER_HOME is unknown

Viewed 1989

I use react native v 0.61.5, Android studio 3.6.3 and macOS Catalina 10.15.4. After update andrid studion, in the android studio has issue:

Exception in thread "main" java.lang.RuntimeException: Base: GRADLE_USER_HOME is unknown at org.gradle.wrapper.PathAssembler.getBaseDir(PathAssembler.java:97) atorg.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:43) at org.gradle.wrapper.Install.createDist(Install.java:44) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

I try to change gradle version and gradle plugin version, delete cache.

Gradle-wrapper.propretise

distributionBase=GRADLE_USER_HOME 
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
2 Answers

Maybe NDK location is the issue : Try to go to File->Project Structure->SDK Location and add NDK location

I specifically experienced this error after installing Android Studio 4.0.1. After searching for long, this is how I solved it:

i. You must first install gradle (latest version is usually recommended) by downloading from Gradle website and extract to a folder of your choice (e.g c:\Gradle )

ii. Add the bin directory of the gradle folder to your PATH environment variable. See this link for details

iii. Delete all .lock files in your project's .gradle folder(if available)

iv. Make sure you upgrade your buildscript dependencies classpath in your project's build.gradle file, to the corresponding gradle version you installed. see the Gradle plugin page for the list of gradle plugin versions and required gradle version. Like this:

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

v. If you enncounter "invalid type code" error, then

Related