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

Viewed 60352

My XML layout is not rendering with this error message. I am already using Java 8.

enter image description here

Also using latest build tools in Gradle.

android {
    compileSdkVersion 'android-N'
    buildToolsVersion 24.0.0 rc1
    ...
}

XML Error -

enter image description here

17 Answers

I had faced the same problem. Please make sure that you are rendering the XML layout for the compiled SDK version (Must not be greater) . Means you will face this if you are compiling the code using Targeted SDK version 23 and your trying to render the XML in SDK version 24.

There are several thing to remember when set the STUDIO_JDK on Mac OS:

  • by default Apple's Java 1.6 is used to start the Android Studio
  • when the STUDIO_JDK is set to Oracle's Java it will be used by the Android Studio to run

The difference between two is that Apple's Java IMO provides nicer and better fonts antialiasing in the IDE.

A reply here is referencing a bug in Android Studio regarding the fonts antialiasing. The ticket is already closed but still rendering is different for Apple Java and Oracle SDK (I have v1.8.0_102). And the former still has better perception than the last.

try to use in project Java 1.8 - download last version of JDK and install it(if JSK is absent)

Then add to build.gradle these lines android { ... // Configure only for each module that uses Java 8 // language features (either in its source code or // through dependencies). compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } // For Kotlin projects kotlinOptions { jvmTarget = "1.8" } }

Related