You can also point Android Studio to use a later version of Java. When updating Android Studio, the fix applied here will continue to be effective. The net effect is that on relaunch of Android Studio, the JVM version indicated in the ist will no longer need to be modified (although since 1.6 is obsolete, I think it should be removed from all future releases).
Delete old JDK files (You will need the admin password).Paste in the following : /Library/Java/JavaVirtualMachines.Press Cmd-Shift-G to open a Go to folder Menu.In my case, I had an old JDK version referencing 1.6 (which is now obsolete) in the following folder: You may experience other error messages at this point that still reference Java 1.6. This will ensure that Android Studio picks up the latest JVM (and incidentally will also fix most other java based apps). Instead install the latest version of the JRE, JDK, and Java Package (from Apple). I found that one needs to remove Java 1.6 since it is no longer supported by OS X 10.11+. If you still prefer to use your own version of JDK, the instructions below still apply.
Navigate to File > Project Structure > SDK Location and choose option to use the embedded JDK. Current versions of Android Studio (2.2.2+) have OpenJDK8 embedded which resolves many of the issues surrounding use of Java 1.6.