Unity gradle build - Error while merging dex archives
Someone in the thread from unity forum finally posted a working solution. I'm gonna share it here as well so hopefully everyone who lands on the question with this issue will not have to spend 30 hours blindfolded resolving dex merging conflicts like I did.
Turns out that with the newer version of unity there is a few more options in the publish settings
that needs to be set!
quoting RealPpTheBest s' answer
Go to player settings > Project Settings > Minify, in there, there will be an option of Release, set it to Gradle .
For some reason when choosing gradle build these two are not automatically toggled, and maybe in some cases they don't have to be. But setting minify to Gradle (experimental)
completely resolved all the build errors I was getting after updating unity.
EDIT: september-2019 - Solution above should still work, but:
I have lately been experimenting with choosing Proguard
instead of the experimental Gradle minifier (can be selected in the dorpdown as well). When configured correctly proguard will also resolve your DEX limitation errors, and get rid of unused code and even compress your build size even more.
This post has a quite throughly detailed guide on how to enable and configure it. Keep in mind though, that the configuration will be unique to which dependencies you are using, so you will have to read up and do some custom configuration here most likely.