I'm a little addicted to it, so it's a post with notes.
The other day, I got a new Mac, so I installed Android Studio and built a development environment. (Just install it.) The construction was completed, and I was able to execute the application without any problems by popping Android Studio, and I was proceeding with the development. So, when I tried to perform a Gradle task in the terminal,
No Java runtime present, requesting install.
And an error ...
I tried various things, "I was able to run it in Android Studio, but why do I get an error that Java is not included ...?"
Yes, it was mentioned on the official website. https://developer.android.com/studio/intro/studio-config.html?hl=ja#jdk
You mean that you had a JDK in Android Studio and you were using it.
You can also check it from [File]> [Project Structure]
in Android Studio. (↓ capture)
What's more, it says recommended
, so I knew that it was better to use the bundled OpenJDK.
I understand why Java isn't available in the terminal. So, you can download it from the Oracle page, but I want to use it with the JDK bundled with Android Studio because it is a good idea. (On the contrary, it is better to unify it because it does not cause strange differences?)
Well, the method of passing the Java path is explained on many sites, so I will omit it, but it was OK with the following feeling.
.bash_profile
export PATH=$PATH:/Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home/bin
export JAVA_HOME=/Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home
You should now be able to perform Gradle tasks in your terminal without any issues: grinning:
Described how to use the JDK used in Android Studio in the terminal. I also found that it is recommended to use the bundled JDK.
Now that the environment is in place, we'll develop it: muscle:
Recommended Posts