How to fix “Android N requires the IDE to be running with Java 1.8 or later” on Mac?

Standard

I get this error while I was in layout editor selecting api N for preview, It was so easy to fix,

  1. install jdk1.8
  2. Set “JDK_HOME” and “JAVA_HOME” environment variables.
  3. Edit the file “/Applications/Android Studio.app/Contents/Info.plist"
  4. Look for “JVMVersion”
  5. add “1.8*,1.8+” to it:
...
<key>JVMVersion</key>
<string>1.8*,1.8+</string>
...

Now restart your “Android Studio”