3

I'm trying to compile ics-openconnect android application(https://github.com/cernekee/ics-openconnect).

I followed that 'ReadMe'. But, when I try to debug, it occurs error.

error:

-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

I know that the version 52.0 means 'jdk 1.8' but I installed only jdk 1.6

how can I fix it?

1
  • Means your android class was compiled against jdk 8.
    – SMA
    Sep 12, 2016 at 16:51

1 Answer 1

6

Your question actually contains the answer. Each class has the version field, which consists of two words: Major and Minor version numbers. The version follows the java signature "CAFEBABE". For class to be loaded, the signature must be correct, and the Major Version should be less or equal to the one supported by the active JRE (Java Runtime Environment). In other words, if you want to load classes that have Major Version word set to 52, you should use Java 8 runtime. Otherwise you get the exception shown in your output. So there are only two options: 1: Install Java 8 runtime. Or 2: Use only packages built with Java 6 SDK.

1
  • oh it's working!!! Thank you so much. I was idiot:( I installed jdk 1.8
    – 김유진
    Sep 12, 2016 at 17:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.