Everytime I get a new computer, I install Java on it, and then Android Studio. And everytime I have to remember how to set ANDROID_HOME and JAVA_HOME. And I forget, and do the same Google searches πŸ˜„. So I’ve decided to write it down this time.

In your home directory, create this .profile file.

# more info https://goo.gl/YHmHGp
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/nazmul/Library/Android/sdk
export PATH="/Users/nazmul/scripts:$PATH"
launchctl setenv ANDROID_HOME $ANDROID_HOME
launchctl setenv JAVA_HOME $JAVA_HOME

Now replace all the /Users/nazmul folders with your username!

Then restart Terminal, and you are good to go.

This will work for launching Android Studio from Finder as well. Since if you don’t do the launchctl stuff, your environment variables will be set when you’re in Terminal, but not when you launch something from Finder.

πŸ‘€ Watch Rust πŸ¦€ live coding videos on our YouTube Channel.



πŸ“¦ Install our useful Rust command line apps using cargo install r3bl-cmdr (they are from the r3bl-open-core project):
  • 🐱giti: run interactive git commands with confidence in your terminal
  • 🦜edi: edit Markdown with style in your terminal

giti in action

edi in action

Related Posts