Davoud
Davoud

Reputation: 2923

How to change Android studio JRE default path?

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Android\android studio\jre\bin\java.exe

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org
Exception: Gradle task assembleDebug failed with exit code 1

Android Studio version:

Android Studio Electric Eel | 2022.1.1 Canary 9 Build #AI-221.5921.22.2211.8881706, built on July 29, 2022 Runtime version: 11.0.13+0-b1751.21-8125866 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Upvotes: 4

Views: 2301

Answers (2)

omral
omral

Reputation: 61

After Android Studio Electric Eel | 2022.1.1 update, JAVA_HOME path is changed jre->jbr. So, you should update .zshrc file.

From terminal,

  1. Type open ~/.zshrc and update the path

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home

  1. To apply changes, you need to restart the terminal

Upvotes: 6

Graeme
Graeme

Reputation: 427

Not sure if this is what you need, but you can change the Java JDK that Gradle uses by going to Settings -> Build, Execution, Deployment -> Build Tools -> Gradle and change the Gradle JDK settings.

You can also change the JAVA_HOME environment variable (not sure if name is the same on different OS) or "changing org.gradle.java.home in gradle.properties."

Upvotes: 1

Related Questions