Android plugin conflict: Unable to convert classes into dex format

I am trying to integrate Mobile Social Plugin (Unity Asset Store - The Best Assets for Game Making) into my Android game. I already have several other plugins including Admob Ads and Google Play Games services and Unity IAP.

I did have some problems getting it to work and the support team helped me in this thread:
http://forum.unity3d.com/threads/released-mobile-social-plugin.229961/page-7#post-2601452

They emailed me a google-play-services.jar file to put in my project, which I did.

Now when I try to build I get this error:

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

The console spits out this (edited & updated 14th July):

CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:/Program Files/Java/jdk1.8.0_92\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="E:/Matt/AppData/Local/Android/sdk	ools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -
stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest$ErrorCode;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest$Gender;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdSize;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter$zza;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter$zzb;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter$zzc;

I’ve emailed the support team again but just wanted to open this up to you kind folks to see if I can speed this up. I’m tantalisingly close to hitting beta just as soon as I can get this working!

I’ve done some digging around and from what I can see this is caused by conflicts with some JAR files in my project. Some people have said they delete a support jar and it works, while others are deleting duplicate classes within the jar.

This is the full list of all .jar files in my entire project:

How can I find out where the problem lies and what steps to take to solve it?

This issue you’re experiencing happens due to multiple native Android plugins containing the same compiled Java classes (e.g: JARs, .AARs or Android library projects). These plugins contain compiled java classes, and for some reason, in your scenario, the build process is attempting to add 2 or more of the same java class to the final output package.

Sometimes, it will be easy to resolve the issue just by finding out if you have 2 or more JAR files with the same name (that contain the same classes).
Unfortunately, JARs and AARs can contain dependant libraries internally, meaning that you won’t be able to find out where the duplicate is so easily.

According to the error message, the problem is with duplicated classes that are related to Google ads. This can give you a lead on where to look for the answer.

NOTE: In some cases, it can get a bit tricky to find out why the build fails. If all else fails, I offer a service on Fiverr to help fix Android related build issues (due to manifest merging, conflicting plugins, etc). Check it out if you’re unable to resolve your issues !

This happened to me as I installed Unity Monetization 3.0, I was getting a smiliar Dex error message and supposedly this happens whenever you have duplicate files in your library, problem was I didn’t have any duplicates at least on my assetsgame folder BUT there is a folder under Project called Packages and there was a folder called com.unity.ads the route for me was C:\Users\myuser\AppData\Local\cache\packages\packages.unity.com</b> and it was the cause of my problem when I put show in explorer there was a folder called com.unity.ads@2.0.8

Solution for me was to erase that folder, after that compiling was not an issue at all, hope this is useful despite the time.

I had this problem too and was able to solve it through the steps below.
First study the error e.g Landroid/support/v4/accessibilityservice … means that you have a file/library called ‘android-support-v4…’ or ‘android.support.v4…’ that is causing this problems. Just look for a .jar file with that name and delete it.


If the file name isn’t called that, you need to decompile the .jar file online to view its contents online here http://www.javadecompilers.com you can then inspect the format of the jar file and see whether it conforms to the error that you were getting in unity. See picture below for details

Good luck!