java.lang.UnsupportedClassVersionError: com/google/doclava/Doclava : Unsupported major.minor version 51.0 android build

自作多情 提交于 2019-12-24 00:13:58

问题


I am trying to build by own AOSP from google source. I follwed the steps mentioned in the Google Documents and was successfully able to build it and flash my device with the images successfully. However, I tried building it again after making some changes (basically just added some Logs to play around with it). The build errored out. I then tried to make again, it said Javac 1.6 found. Required Javac 1.7. I then followed the answers for this particular problem by using the following command:

 update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-openjdk-amd64/bin/javac   1051      auto mode
* 1            /usr/lib/jvm/j2sdk1.6-oracle/bin/javac        315       manual mode
  2            /usr/lib/jvm/java-7-openjdk-amd64/bin/javac   1051      manual mode

I then selected the option 0. I then tried to make again. This time it failed with the following error:

java.lang.UnsupportedClassVersionError: com/google/doclava/Doclava : Unsupported major.minor version 51.0 android build

After going through the all answers for this question(I found this asked so many times), I found it is because the complie time(higher version) and run time(lower version) JDK dont match and I should recompile it using Java 1.7. How do I do that for android build? I am also surprized why I got the error "Javac 1.6 found. Required Javac 1.7." as I successfully created the build using Java 1.6.


回答1:


In this case it's not the problem with javac, but with javadoc. To check its version: javadoc -J-version (yes, it's weird).

So, you have to use:

update-alternatives --config javadoc



回答2:


This error means you're trying to load a Java "class" file that was compiled with a newer version of Java than you have installed.

For example, your .class file could have been compiled for JDK 7, and you're trying to run it with JDK 6.

So the solution is to either:

  • Upgrade your Java runtime or
  • Recompile the class if you have the source, using your local Java compiler (if you have one).

    javac FileName.java

visit this more detail: How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version



来源:https://stackoverflow.com/questions/37112545/java-lang-unsupportedclassversionerror-com-google-doclava-doclava-unsupported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!