At present I am facing problem by using multiple plugin.
I have integrated three plugin into same project named as
Admob Ads
Mobile Social Plugin
IABCombo
First I have first two plugins implemented and everything works fine next I add third plugin, it now showing following message when I try to build it in android.
Following image represent generated message.
As per my analysis for this problem is that:
Unity combine all jar files classes and then use it. So at present there are multiple copies of classes exist after adding third plugin.
I can’t able to figure out how to handle this problem??
Provide some guidance about this problem because I know there are lots of developer facing same problem.
First off, for general knowledge, DEX is the process that takes code files (whether it’s your code, or code that is provided in libraries) and converts it into the DEX format (Dalvik Executable).
Libraries are only used for convenience during development: when you build your game, there’s no notion of libraries anymore - it’s all just compiled code.
For this reason, when 2 or more plugins reference the same library (contain 2 copies of a referenced JAR) or define a class with the same name, a conflict occurs, causing this error.
For example: if you are using 2 plugins in your Unity project and both contain a copy of GooglePlayServices.jar, DEX will fail to build your game, since it will try to process multiple copies of the same class.
In your case, it is not clear whether this is the case (multiple copies of the same jar) or whether it’s multiple copies of the same class.
The first one is easier to spot (look for multiple copies of the same JAR). the 2nd one is trickier but it will help if you provided some more information (e.g: is there any extra information in the Unity console? the DEX tool should provide the name of the class that causes the failure for example).
NOTE: In some cases, it gets tricky to find out why the build fails. If all else fails, I offer my help to fix Android related build issues (due to manifest merging, conflicting plugins, etc). Check it out if you’re unable to resolve your issues !
Thanks for this nice explanation. I think in my case, there are multiple copies of class file exist among jar files. So how to track these problem as per your consideration? One more thing I up vote your answer for clear explanation.
Is there any more information in the unity console? usually the DEX tool should tell you exactly what's causing the error. For example, see this: http://answers.unity3d.com/questions/672365/unable-to-convert-classes-into-dex-format.html The error shown in the console is stderr[ UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Landroid/support/v4/hardware/display/DisplayManagerCompat; In your case it should also show what class was already added and is attempted to be re-added to the DEX.
Thanks for your help. Now I clearly understand problem that cause this type of error and successfully solved that one. I modify jar file content and then used new one that conflict with other jar files.
When I want to build I have the same error. (unable to convert classes into dex format) Here is the error: http://pastebin.com/kS7rESRe I can't figure out what's the problem...I deleted same .jar files. Anyone can help me?
Thanks it helped. I had an issue after upgrading Fabrics where for some reason it kept the old associated jar files (ie crashlytics, crashlytics-core, beta, fabric, answers) on top of the new ones. After a search in my project for the respective .jar files, I deleted the old versions.
I once had that problem with Google Play Game Services and Facebook SDK v7.4.0
there was 2 files support-v4-23.0.0 and support-v4-23.1.1
so i just remove the last one and it worked
Hey! I have the exact same problem, unfortunately I haven't been able to solve it yet as I can't delete my support-v4-23.4.0.aar file?!?! any suggestions? Every time I delete it and restart Unity it just appears again! Thanks, -Andrew
I once had that problem with Google Play Game Services and chartboost ads. The problem lies precisely where you think. The chartboost ads classes were in conflict with those from google play (same name classes for ads). Hence the ads were displayed only via chartboost, the solution was to remove them from the other jar (Google play games). I just changed google play games jar to zip, and opened it in total commander (jar is like zip, you can use any software), than i removed ads folder (could not recall the exact name), changed extension back to jar, and voila I could build without problems
Another similar problem on dex classes that I once had,was that I got new plugin that required the newest JDK, hence JDK update solve the issue. The best would be if you will copy full error message from console.
Full error message represented in following image [30576-errorbuildplayer.png|30576] Also I want to ask one more question that I read in some post. Whether I have to do anything with UnityPlayerNativeActivity? Any sub classing related stuff? or this is totally unrelated here.
We had Chartboost and Google Play services in our project and the issue for us was this line in the Chartboost android manifest that was duplicate in other manifests.
i have the same issue i cannot find this line in chartboost android manifest, but i had found in plugin/android/android manifest/under required by chartboost this line was there. then i deleted that line and builded it again same error [115791-error.jpg|115791]
In the case of plugins where you can enable or disable libraries, choosing the right ones to disable could help. This was what I did with Stan’s Assets’ Ultimate Mobile Settings.
Thanks for this nice explanation. I think in my case, there are multiple copies of class file exist among jar files. So how to track these problem as per your consideration? One more thing I up vote your answer for clear explanation.
– siddharth3322Is there any more information in the unity console? usually the DEX tool should tell you exactly what's causing the error. For example, see this: http://answers.unity3d.com/questions/672365/unable-to-convert-classes-into-dex-format.html The error shown in the console is stderr[ UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Landroid/support/v4/hardware/display/DisplayManagerCompat; In your case it should also show what class was already added and is attempted to be re-added to the DEX.
– liortalThanks for your help. Now I clearly understand problem that cause this type of error and successfully solved that one. I modify jar file content and then used new one that conflict with other jar files.
– siddharth3322When I want to build I have the same error. (unable to convert classes into dex format) Here is the error: http://pastebin.com/kS7rESRe I can't figure out what's the problem...I deleted same .jar files. Anyone can help me?
– GabeGabeThanks it helped. I had an issue after upgrading Fabrics where for some reason it kept the old associated jar files (ie crashlytics, crashlytics-core, beta, fabric, answers) on top of the new ones. After a search in my project for the respective .jar files, I deleted the old versions.
– Binbag42