问题
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