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

后端 未结 17 1370
无人共我
无人共我 2020-11-27 10:58

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

Also using latest build tools in Gradle.

and         


        
相关标签:
17条回答
  • 2020-11-27 11:56

    I met the same issue.

    I installed jdk1.6,jdk1.7,jdk1.8, and deployed Studio as what you did.

    My solution is uninstall jdk1.6 and jdk1.7, only leave jdk1.8

    sudo rm -rf ${path to jdk1.6}
    sudo rm -rf ${path to jdk1.7}
    

    That's all.

    0 讨论(0)
  • 2020-11-27 11:56

    I'm using Ubuntu 14.04 and I was facing a similar error, with the difference I don't have NDK. My solution was, after setting up Java 8 in project definition, reboot Android Studio, no more.

    Check system Java version, in console "java -version", output should say something like this

    java version "1.8.0_91"
    
    0 讨论(0)
  • 2020-11-27 11:56

    Had the same problem with Ubunutu. The problem was not running the IDE with Java8.

    I fixed it with updating the default java program of the OS, using:

    sudo update-alternatives --config java
    

    And choosing the relevant Java8 path.

    0 讨论(0)
  • 2020-11-27 11:57

    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.
    0 讨论(0)
  • 2020-11-27 11:58

    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.

    0 讨论(0)
提交回复
热议问题