Reputation: 2106
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
Reputation: 71
The issue is solved for me only by doing clean the project.
steps:
Upvotes: 0
Reputation: 21
Navigate to the 'Android' folder.
Find & open the file named 'gradle.properties'.
Remove the following line (anyone you find)
Save the file and run the command 'npx react-native run-android'. That's it!
Upvotes: 2
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
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
Reputation: 11
If you use visual studio code open the folder android\gradle.properties.
Delete This line org.gradle.java.home= C:\Java\jdk1.8.0_361
Upvotes: 1
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
Upvotes: 1
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
Reputation: 449
Check the global gradle configuration in C:\Users\<user>\.gradle
In your android project you will have a file named gradle.properties
Delete org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_144
Upvotes: 44
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
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
toAndroid Studio 4.1.3.app
since I have multiple installations.
Upvotes: 4
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
Reputation: 21
android\gradle.properties
.org.gradle.java.home = <local path>\Java\jdk1.8.0_144
, e.g. C:\Program Files\Java\jdk1.8.0_191
Upvotes: 2
Reputation: 1246
org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_144
Upvotes: 24