roconmachine
roconmachine

Reputation: 2106

Java home supplied via 'org.gradle.java.home' is invalid. Invalid directory: /usr/local/java/jdk1.8.0_05

I'm using gradle 2.9, intellij and Win10 for spring development. In one particular project I encountered this error:

Java home supplied via 'org.gradle.java.home' is invalid. Invalid directory: /usr/local/java/jdk1.8.0_05

Neither solution 1 nor solution 2 work for me.

Upvotes: 53

Views: 138243

Answers (13)

FAROOQ AHMAD
FAROOQ AHMAD

Reputation: 71

The issue is solved for me only by doing clean the project.

steps:

  1. Restart your IDE.
  2. flutter clean
  3. flutter pub get

Upvotes: 0

Muhammad Bilal
Muhammad Bilal

Reputation: 21

  1. Navigate to the 'Android' folder.

  2. Find & open the file named 'gradle.properties'.

  3. Remove the following line (anyone you find)

    • org.gradle.java.home=C:\Program Files\Java\jdk-17
    • org.gradle.java.home=C:\Program Files\Java\jdk-17
  4. Save the file and run the command 'npx react-native run-android'. That's it!

Upvotes: 2

Firdous nath
Firdous nath

Reputation: 1587

After updating to android studio giraffe I changed jre to jbr on M1 mac

org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/Contents/Home/

org.gradle.java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home/

Upvotes: 5

Shahadat Hossain
Shahadat Hossain

Reputation: 543

Open android/gradle.properties and check /usr/lib/jvm/java-8-openjdk-amd64 this line available or not. If available, then comment out/remove this line and try to run.

This works for me.

Thank you

Upvotes: 0

Abid Malik
Abid Malik

Reputation: 11

  1. If you use visual studio code open the folder android\gradle.properties.

  2. Delete This line org.gradle.java.home= C:\Java\jdk1.8.0_361

check screenshot

Upvotes: 1

Navin Kumar
Navin Kumar

Reputation: 4027

For Mac M1 chip users, add the following line in gradle.properties

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
org.gradle.java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home //////-ADD THIS LINE ONLY

you can find your java home path

AndroidStudio -> File -> ProjectStructure -> SDKs -> Android studio java home

Java Home Path

Upvotes: 1

Ali Panahi
Ali Panahi

Reputation: 27

Delete this line:

org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

from gradle.properties. This will work for you.

Upvotes: 1

Warke.shi
Warke.shi

Reputation: 449

  1. Check the global gradle configuration in C:\Users\<user>\.gradle

  2. In your android project you will have a file named gradle.properties

  3. Delete org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_144

Upvotes: 44

salvi shahzad
salvi shahzad

Reputation: 1261

In my case, I removed this line from my android/gradle.properties:

org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

And then I edited my android/local.properties and gave the right sdk directory path which can be found in android studio -> preferences -> Appearance & behaviour -> System settings -> Android sdk

Apparently I moved my code from one machine to another so the sdk path was not correct.

Upvotes: 3

ViliusK
ViliusK

Reputation: 11555

For anyone on MacBooks, you might want to check if the file in /Users/username/.gradle/gradle.properties has the correct JDK path provided.

I was receiving the following message in Android Studio:

Value '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home' given for org.gradle.java.home Gradle property is invalid (Java home supplied is invalid)

My gradle.properties file had the following line:

org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

And I had to change it to the following:

org.gradle.java.home=/Applications/Android Studio 4.1.3.app/Contents/jre/jdk/Contents/Home Since I renamed Android Studio.app to Android Studio 4.1.3.app since I have multiple installations.

Upvotes: 4

roconmachine
roconmachine

Reputation: 2106

Finally I found my solution. In the project root I found gradle.properties configure this java home

 org.gradle.java.home=/usr/local/java/jdk1.8.0_05

I remove and build it properly.

Upvotes: 94

Azhakesan T
Azhakesan T

Reputation: 21

  1. If you use visual studio code open folder android\gradle.properties.
  2. Change the path org.gradle.java.home = <local path>\Java\jdk1.8.0_144, e.g. C:\Program Files\Java\jdk1.8.0_191

Upvotes: 2

Atif Mukhtiar
Atif Mukhtiar

Reputation: 1246

  1. In your android project you will have a file name gradle.properties.
  2. Open up that file, there will a line

org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_144

  1. You will have to change this line, insert your jdk setup location, most important use double backslashes "\\" like above in your path.

Upvotes: 24

Related Questions