- Home /
Android plugin conflict: Unable to convert classes into dex format
I am trying to integrate Mobile Social Plugin (https://www.assetstore.unity3d.com/en/#!/content/15066) 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\tools" -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?
Update: I've also tried going through the google-play-services.jar and removing any class that spits out a build error. Eventually it just dumped me back to the starting problem where my AP$$anonymous$$ crashes on launch.
Any update on this @CrowbarSka, i am stuck with the same problem removing classes / or jars is not helping.
I got some help from the plugin developer, but unfortunately I don't know exactly how they fixed it.
I recently updated to Unity 5.3.5f1 and the issue has reappeared, so I'm back in the same boat. I'll be having another look at it next week.
Sorry I can't be more help at the moment.
Thanks for your help @CrowbarSka, i followed most of the answers posted in the forum but i couldn't solve this, no duplicate jars and no duplicate class files also, Lastly I just gave a try by switching Unity IAP 'OFF' and back 'ON' for some strange reason it worked its starting building fine for me so I'm not sure how.
hi i have the same problem if you solve this problem so can you sen me the solution ??
see my answer below. you have duplicate libraries in your project.
Answer by FallingRocketGames · Feb 01, 2019 at 12:04 AM
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\ 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.
Answer by liortal · Jul 15, 2016 at 09:12 AM
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 !
Answer by cherucole · Apr 17, 2019 at 10:15 AM
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!