Needed to download Android Studio at work work and it didn't work.
Android Studio was unable to find a valid JVM.
Open up Script Editor
do shell script "launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk"
Save this as an Application.
Change the version to your version:
In the Terminal:
javac -version