Unable to convert classes into dex format. Using only Google Cardboard in Unity (Mac)

Hi guys,

Normally I wouldn’t post but I have literally run out of ideas. I have been searching through the forums trying to find a solution to an error I am repeatedly getting.

“Build failure
Unable to convert classes into dex format. See the Console for details.”

This always happens when trying to build and run at the “Converting java.class to dex-format…” stage.

I am trying to get the Google Cardboard SDK for Unity working on Android. I am using Unity 5.3.4fi Personal on OS X Yosemite 10.10.5. I have gone through many threads and forums trying to work out what the problem might be. From what I can decipher, this error is usually caused by duplicate .jar files and often linked to using multiple plugins. The strange thing is that I am using a completely blank project, importing the Google Cardboard Unity SDK, adding the Cardboard prefab to the stage and then attempting a build. I have also searched for .jar files in finder and there are no duplicate .jar filenames other than the ones in the Temp folder.

I have also tried removing the Cardboard folders and assets and using the Durovis Dive SDK instead. I get the same issue.

I have made VR apps before in Unity 4.6 and never had these issues, so I have no idea what is going on. I literally won’t be able to make any VR games unless I can get this stupid issue fixed.

If anyone has nay suggestions or similar experiences, it would be a massive help and you would be preventing premature hair loss.

If you need further information, please ask.

Many thanks.

I’m encountering the same problem. The only tweak i came across with is if i delete plugins folder from cardboard SDK and uncheck virtual Reality in build Setting i can compile it but for the cost of just solid color view. I’m using controller for movements and when i use the controller i can hear movements etc. but no visuals. So, there must be something wrong with either googleCardboard VR settings or unity VR settings but i still can’t figure this out maybe you can have any luck finding the problem and if you find one kindly post it here too.

Yes of course. I am still searching but can’t seem to solve it. I might have to try completely reinstalling Unity, Android and JSK as a last resort. I am running out of ideas.

Ok, so I have manage to sort it out now. I completely removed Android Studio and ALL versions of Java and JDK and then reinstalled them. Through the process, there are a few things that I noticed, which may have been the reason for the errors, however I don’t know for certain…

First of all I had more than 3 versions of JDK on my Mac. Secondly, when I installed Android Studio I copied it over a previous version and wasn’t greeted with the setup wizard when I opened it for the first time. This then meant that I had to add the platform and tools manually in Android Studio, which may or may not have been the issue.

What I did

You might want to grab a coffee for this as there a few websites to read and re-installing Android Studio takes a while.

  1. Completely removed Android Studio in Terminal as shown here: macos - How to completely uninstall Android Studio on Mac? - Stack Overflow

  2. Completely removed Java as outlined here: http://www.howtogeek.com/230145/how-to-uninstall-java-on-mac-os-x/ - This is the point where I noticed that there were several versions of JDK. When checking the contents of the “JavaVirtualMachines” folder there were 2 files listed. I followed the steps to delete them, but simply pressing tab won’t work because there are 2 files starting with “jdk1”, so just type a bit more of the file name, then press Tab.
    The last point of the guide says to type “java” in Terminal to make sure it has completely gone. I noticed that there was a 1.6.0 version of JDK, which after a quick Google search turned out to be in another folder. So I typed in terminal “cd /System/Library/Java/JavaVirtualMachines/” to get to the folder, then “ls” to list its contents, then “sudo rm -rf 1.6.0.jdk/” to delete the remaining version. I then typed “java” again to confirm that everything was gone.

  3. I re-installed JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  4. I re-installed Android Studio from http://developer.android.com/sdk/index.html#Other - This time I was met with the setup wizard and followed the recommended settings.

  5. I set up an entirely new Unity project, adjusted the player settings to have a proper bundle identifier etc. then installed the Unity Cardboard SDK from https://developers.google.com/cardboard/unity/download and added the Cardboard Main prefab to the scene.

  6. I plugged in my phone, went to build and it asked me to locate the JDK location and then said it needed to update the Android SDK, which it did and then finally I had the content working on my device.

Hope this solves the issue for you and hopefully the next time someone encounters the issue they will be able to see this solution and not have to bang their head against a wall like I have for the past few days.

Let me know if it works for you and if you have any insight into the route of the problem, it would also be useful for future reference.

Ok, so I have manage to sort it out now. I completely removed Android Studio and ALL versions of Java and JDK and then reinstalled them. Through the process, there are a few things that I noticed, which may have been the reason for the errors, however I don’t know for certain…

First of all I had more than 3 versions of JDK on my Mac. Secondly, when I installed Android Studio I copied it over a previous version and wasn’t greeted with the setup wizard when I opened it for the first time. This then meant that I had to add the platform and tools manually in Android Studio, which may or may not have been the issue.

What I did

You might want to grab a coffee for this as there a few websites to read and re-installing Android Studio takes a while.

  1. Completely removed Android Studio in Terminal as shown here: macos - How to completely uninstall Android Studio on Mac? - Stack Overflow

  2. Completely removed Java as outlined here: http://www.howtogeek.com/230145/how-to-uninstall-java-on-mac-os-x/ - This is the point where I noticed that there were several versions of JDK. When checking the contents of the “JavaVirtualMachines” folder there were 2 files listed. I followed the steps to delete them, but simply pressing tab won’t work because there are 2 files starting with “jdk1”, so just type a bit more of the file name, then press Tab.
    The last point of the guide says to type “java” in Terminal to make sure it has completely gone. I noticed that there was a 1.6.0 version of JDK, which after a quick Google search turned out to be in another folder. So I typed in terminal “cd /System/Library/Java/JavaVirtualMachines/” to get to the folder, then “ls” to list its contents, then “sudo rm -rf 1.6.0.jdk/” to delete the remaining version. I then typed “java” again to confirm that everything was gone.

  3. I re-installed JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  4. I re-installed Android Studio from Download Android Studio & App Tools - Android Developers - This time I was met with the setup wizard and followed the recommended settings.

  5. I set up an entirely new Unity project, adjusted the player settings to have a proper bundle identifier etc. then installed the Unity Cardboard SDK from https://developers.google.com/cardboard/unity/download and added the Cardboard Main prefab to the scene.

  6. I plugged in my phone, went to build and it asked me to locate the JDK location and then said it needed to update the Android SDK, which it did and then finally I had the content working on my device.

Hope this solves the issue for you and hopefully the next time someone encounters the issue they will be able to see this solution and not have to bang their head against a wall like I have for the past few days.

Let me know if it works for you and if you have any insight into the route of the problem, it would also be useful for future reference.

i have the same problem, but now it working because i try to update my JDK1.7.0_79 to new JDK1.8.0_112 and now problem solve…! i’m using windows 64 bit with unity 5.4.0f3…