How to: Solve the “Unable to convert classes into dex format” Unity error – the return….

Back in 2014 I blogged about how to solve the “Unable to convert classes into dex format” Unity error.

I thought I’d post a follow up as I had the same error recently but with a slightly different message and cause. The error was:

UNEXPECTED TOP-LEVEL EXCEPTION:

java.lang.IllegalArgumentException: already added:
Lcom/google/android/gms/analytics/ExceptionReporter;

I looked for ExceptionReporter and found it in:

Assets/Plugins/Android/google-play-services_lib/libs/google-play-services.jar
Temp/StagingArea/android-libraries/google-play-services_lib/libs/google-play-services.jar
Temp/StagingArea/android-libraries/play-services-analytics-7.5.0/bin/classes.jar

The original error report also said:

Created unique file for imported asset as file exists with different
GUID (Assets/Plugins/Android/MainLibProj/libs/play-games-plugin-support.jar
=> Assets/Plugins/Android/MainLibProj/libs/play-games-plugin-support
1.jar)

When the asset is renamed it causes the problem. However, in the end I found that the problem was caused by these duplicate files:

Assets/Plugins/Android/android-support-v4.jar (ARMv7)
Assets/Plugins/Android/libs/android-support-v4.jar (ARMv7)

So, you can fix the issue by removing one of the files (or choosing a different architecture if that’s appropriate for your project).