Android N requires the IDE to be running with Java 1.8 or later?
I got the same error you describe but on OS X. I know this may not solve your problem (because I don't know the equivalent for Windows), but since this is not OS specific I am leaving the solution for any OS X fellow out there.
Edit the file /Applications/Android\ Studio.app/Contents/Info.plist
, and remove the 1.6 version (in my case), you may place 1.6+, 1.7+ or 1.8, whichever you prefer. Mine ended up like this
...
<key>JVMVersion</key>
<string>1.7+</string>
...
Be aware there's an incompatibility with drag and drop with java versions 1.8_60 to 1.8_75 (IDEA-146691) which the IDE will report once you successfully change the version.
For non Terminal Users
- Find your
Android Studio.app
file. If it's in the dock you can right click it and chooseOptions > Show in Finder
. - Right click it and choose
Show package content
. - Navigate to the mentioned file (
Contents/Info.plist
). - Edit the file with your favorite text editor.
Set JDK_HOME
and JAVA_HOME
environment variables, in my case C:\Program Files\Java\jdk1.8.0_60
.
Check Java version in Help > About
. It should show the JRE version you just set.
That is it, now you can preview your layout in N
.
Click on the letter N, next to the android icon in the Preview window and select API level 23 or lower. That should solve it.
For Mac users with this issue (I'm running OS X 10.11.5 and Android Studio 2.1.2), here's how you can solve it:
Currently, the Mac version of Android Studio is run with Java 6 (not necessarily the same as the JDK version for the app), because Java 6 has better font rendering than Java 7 & 8, and that's apparently more important than rendering your layout.
First of all, make sure you have JDK 8 installed.
Then run the following commands:
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk
$ open /Applications/Android\ Studio.app/
You may need to change the 91
in jdk1.8.0_91.jdk
to a different version. You can see which JDK versions you have with:
$ ls /Library/Java/JavaVirtualMachines/
Unfortunately, this method requires opening the app from the terminal, but you could always create a script for it.
More info
Edit: And if you really don't want to open it from the terminal:
- Create an AppleScript with contents:
do shell script "export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk; open /Applications/Android\\ Studio.app/"
- File > Save Choose file format Application. Save it somewhere.
- If you want to change the icon, see here.
- Drag the app to your launchpad if you like.