Search Unity

Android Unable to convert classes into dex format

Discussion in 'AR/VR (XR) Discussion' started by jonny2027, Sep 15, 2016.

  1. jonny2027

    jonny2027

    Joined:
    Jul 16, 2013
    Posts:
    61
    Hi all,

    I have downloaded the latest sample framework from Oculus and loaded it into Unity, when i change to android and build everything is fine, but if i tick the VR Support i get the following error. I have tried with various other samples and examples but they all seem to error like this when enabling VR support at the Android level

    I am on a mac 10.11.6, running java version "1.8.0_102", 1.6.0 JDK and have the android SDK installed as part of Android Studio, finally I am using 5.4.0f3 of Unity.

    Any help would be great

    Code (CSharp):
    1.  
    2. CommandInvokationFailure: Unable to convert classes into dex format.
    3. /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/jonny2027/Library/Android/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -
    4.  
    5. stderr[
    6. Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
    7.     at java.lang.ClassLoader.defineClass1(Native Method)
    8.     at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    9.     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    10.     at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    11.     at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    12.     at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    13.     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    14.     at java.security.AccessController.doPrivileged(Native Method)
    15.     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    16.     at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    17.     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    18.     at java.lang.Class.forName0(Native Method)
    19.     at java.lang.Class.forName(Class.java:274)
    20.     at SDKMain.main(SDKMain.java:127)
    21. ]
    22. stdout[
    23.  
    24. ]
    25. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    26. UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    27. UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    28. UnityEditor.HostView:OnGUI()
    29.  
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    574
    Do you have the latest SDK and build tools? This looks like the error you would get if you weren't running Build Tools 24.* I believe.
     
  3. jonny2027

    jonny2027

    Joined:
    Jul 16, 2013
    Posts:
    61
    Hi Joejo,

    I think you are right. I have tried upgrading the sdk and tools but not sure its fixed so might try a fresh android install as I am now getting the following error in the console

    Thanks

    Jonathan

    Code (CSharp):
    1. Failed to compile resources with the following parameters:
    2. -bootclasspath "/Users/jonny2027/Library/Android/sdk/platforms/android-24/android.jar" -d "/Users/jonny2027/Downloads/OculusSampleFrameworkProject_1.5.0/OculusSampleFrameworkProject/Temp/StagingArea/bin/classes" -source 1.6 -target 1.6 -encoding UTF-8 "com/oculus/Integration/R.java" "com/oculus/SampleFramework/R.java"
    3. warning: /Users/jonny2027/Library/Android/sdk/platforms/android-24/android.jar(java/lang/Object.class): major version 52 is newer than 51, the highest major version supported by this compiler.
    4.   It is recommended that the compiler be upgraded.
    5. warning: /Users/jonny2027/Library/Android/sdk/platforms/android-24/android.jar(java/lang/AutoCloseable.class): major version 52 is newer than 51, the highest major version supported by this compiler.
    6.   It is recommended that the compiler be upgraded.
    7. 2 warnings
    8.  
    9. UnityEditor.HostView:OnGUI()
    10.  
     
  4. jonny2027

    jonny2027

    Joined:
    Jul 16, 2013
    Posts:
    61
    I have just checked again the build tools hasnt been updated so thats probably the problem.

    Thanks
     
  5. jonny2027

    jonny2027

    Joined:
    Jul 16, 2013
    Posts:
    61
    I have updated everything, build tools, NDK, SDK etc but i still get this message. Any ideas what might be wrong.
     
  6. JDMulti

    JDMulti

    Joined:
    Jan 4, 2012
    Posts:
    382
    I had this a few times as well, try doing this worked for me.

    - update android SDK
    - update java JDK ( this is I think your issue, as is has some java errors )

    Also notice you get this dex format error also with the following things:

    - windows path too long, so your project path has a too long path ( had this once )
    - your apk goes over 2.1gb filesize. Yes I did this once because I was too laze streaming video and added to app instead

    Can't think of any other issue causing this dex format error.
     
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,346
    You should install JDK 8 to solve this particular error.
     
  8. jonny2027

    jonny2027

    Joined:
    Jul 16, 2013
    Posts:
    61
    Thanks. All sorted now :)
     
  9. AhmedGalal1987

    AhmedGalal1987

    Joined:
    Sep 4, 2016
    Posts:
    3
    How you fix it please ..
    I have same issue for one week :(