Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android N requires the IDE to be running with Java 1.8 or later?

People also ask

Does developing for Android require the JRE or the JDK?

Since Android apps are written in Java, you will need the Oracle Java compiler and libraries on your system. These are collectively called the Java Development Kit or "JDK" for short.

Is Android Studio an IDE for Java?

The short answer to this is : Yes you can. Look over this slackoverflow post: Can Android Studio be used to run standard Java projects? Android Studio IDE is based on IntelliJ, but with some specific plugins added for Android Development.

What version of JDK is required for Android Studio?

A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects.

Is JRE required for Android Studio?

Android Studio is a customized version of JetBrains' IntelliJ IDE, which is, in turn, a Java application. Therefore, as we established, to launch IntelliJ (and, consequently, Android Studio) on your computer, you need to have JRE installed.


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

  1. Find your Android Studio.app file. If it's in the dock you can right click it and choose Options > Show in Finder.
  2. Right click it and choose Show package content.
  3. Navigate to the mentioned file (Contents/Info.plist).
  4. Edit the file with your favorite text editor.

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.

First row of icons in the rpeview window


Set JDK_HOME and JAVA_HOME environment variables, in my case C:\Program Files\Java\jdk1.8.0_60.

enter image description here

Check Java version in Help > About. It should show the JRE version you just set.

enter image description here

That is it, now you can preview your layout in N.


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:

  1. Create an AppleScript with contents: do shell script "export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk; open /Applications/Android\\ Studio.app/"
  2. File > Save Choose file format Application. Save it somewhere.
  3. If you want to change the icon, see here.
  4. Drag the app to your launchpad if you like.