Add RVM stuff and protect ANDROID_HOME stuff in case it's not installed.
Wrap the brew commands with an if statement and figure out the correct JDK path.