我正在尝试编译ics-openconnect android应用程序(https://github.com/cernekee/ics-openconnect)。
我跟着那个"ReadMe"。但是,当我尝试调试时,它出现错误。
错误:-dex:
[dex] input: /home/yj/ics-openconnect/bin/classes
[dex] input: /home/yj/ics-openconnect/libs/openconnect-wrapper.jar
[dex] input: /home/yj/ics-openconnect/libs/acra-4.5.0.jar
[dex] input: /home/yj/ics-openconnect/libs/stoken-wrapper.jar
[dex] Pre-Dexing /home/yj/ics-openconnect/libs/openconnect-wrapper.jar -> openconnect-wrapper-58de756051305e9ad3753d649df24013.jar
[dx] Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
[dx] at java.lang.ClassLoader.defineClass1(Native Method)
[dx] at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
[dx] at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
[dx] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
[dx] at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
[dx] at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
[dx] at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
[dx] at java.security.AccessController.doPrivileged(Native Method)
[dx] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[dx] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[dx] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[dx] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[dx] Could not find the main class: com.android.dx.command.Main. Program will exit.
BUILD FAILED
and, my java:
$java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
javac:
$javac -version
javac 1.6.0_45
我知道版本52.0意味着'jdk 1.8'但是我只安装了jdk 1.6
我该如何修复它?
你的问题实际上包含了答案。每个类都有version字段,它由两个词组成:Major和Minor版本号。版本遵循java签名"CAFEBABE"。对于要加载的类,签名必须是正确的,并且主版本应该小于或等于活动的JRE (Java Runtime Environment)所支持的版本。换句话说,如果您想加载Major Version word设置为52的类,则应该使用Java 8运行时。否则,您将得到输出中显示的异常。所以只有两种选择:1:安装Java 8运行时。或者2:只使用Java 6 SDK构建的包。