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.
Answer by Polygami · Apr 22, 2016 at 11:09 AM
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.
Completely removed Android Studio in Terminal as shown here: http://stackoverflow.com/questions/17625622/how-to-completely-uninstall-android-studio
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.
I re-installed JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
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.
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.
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.
Answer by Qaim Hassan · Apr 22, 2016 at 05:25 AM
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.
Answer by Polygami · Apr 22, 2016 at 08:17 AM
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.
Answer by Polygami · Apr 22, 2016 at 11:09 AM
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.
Completely removed Android Studio in Terminal as shown here: http://stackoverflow.com/questions/17625622/how-to-completely-uninstall-android-studio
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.
I re-installed JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
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.
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.
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.
Thanks mate for your solutions. When you mentioned that you had multiple JD$$anonymous$$s, something clicked in my $$anonymous$$d, as when i was checking the error description in console it was related with some "Virtual$$anonymous$$achine/jdk... "
so, Here what I did!
I followed the instructions from your provided link to uninstall jdk (http://www.howtogeek.com/230145/how-to-uninstall-java-on-mac-os-x/) the older versions of JD$$anonymous$$ and re-installing it (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html).
Then i set up jdk in External Tools in unity>preferences>External Tools i.e "/Library/Java/JavaVirtual$$anonymous$$achines/jdk1.8.0_92.jdk/Contents/Home" for me
Tried out with the same project, It processed through dex conversion but gave me an error for installing apk on device
Created a new project set up basic scene and built the new project and 'Voila' it ran normally on my device.
So, the problem was with multiple versions of jdk conflicting with each other.
$$anonymous$$aybe you can work it out with deleting older versions of jdk ins$$anonymous$$d of completely installing and re-installing it and set up home path for jdk manually in unity. *** Hope this solution might save some of your time for re-installing Android Studio
Answer by domuzx · Nov 04, 2016 at 02:56 AM
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..
Your answer
Follow this Question
Related Questions
Unable to build Google VR app for Android 0 Answers
Google VR (Cardboard) don't work with Render Pipeline Asset. 0 Answers
Android Unable to merge android manifest Error 0 Answers
Overwrote cardboard package now screen is black. Help appreciated a lot! 0 Answers
Android application doesn't automaticly request for microphone permission 1 Answer