Unity UNEXPECTED TOP-LEVEL EXCEPTION

Do you have Unity Facebook Plugin, maybe some Prime31 Plugins too and an error like this:

Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir=”/Users/paespedro/Development/android-sdk-mac_x86/tools” -Dfile.encoding=UTF8 -jar “/Applications/Unity/Unity.app/Contents/BuildTargetTools/AndroidPlayer/sdktools.jar” –

stderr[

UNEXPECTED TOP-LEVEL EXCEPTION:

java.lang.IllegalArgumentException: already added: Landroid/support/v4/util/TimeUtils;

Maybe I have the solution 🙂 … this is actually the second time this is happening to me (I forgot to post about this in the first time)

As you may have found on StackOverflow, this error usually happens because you have a duplicate JAR somewhere on your Asset folder. In my case the villain was Facebook and the solution was to remove “bolts-android”,  “android-support-v4” and “facebooksdk” (on “Plugins / Android / facebook / lib” folder) … do not delete yet, move the duplicated files to your Desktop for example. If you’re still getting errors, other possible duplicates can be found at “Editor / Android / android-libs”. It’s probably better to remove one by one and compile until you stop getting errors 😉

If even removing those duplicates it doesn’t you should try to read more carefully the error message on your console.

Try to locate the duplicate JAR files by searching for the name (“bolts” for example) and move the duplicate ones away from your project folder and try again, in my case, removing the files under “lib” folder from Facebook did the job 🙂

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.