◆ Android Build Error Analyzer (Duplicate Class Error be gone)

Sometimes third party libs add code in the PreProcessBuild step. Or they do not implement the External Dependency Manager properly (Advertisement SDKs, I am looking at you).

How does it work?
To resolve the resulting "duplicate class" errors quickly I've built this tool. It shows which libraries are in conflict and where they are coming from (including gradle files). It's not a pre build tool but a POST build tool. Meaning it will catch errors that the External Dependency Manager is not aware of.

Asset Store Link

1) Analyze the errors after the build and gain insights:


2) List duplicate libraries before the build.


3) Find all libraries in the project.


Hi Geo! I'm having that kind of issues. What should I do with this information? With the information that give us your plugin, how can I solve the duplicate classes errors?

Hi, thank you for asking.

First step would be making sure you have everything committed to your version control system (I'd recommend git). That way you can revert any changes easily.

Find Libs:
Second step would be to check if the "Find duplicate libraries" option shows any duplicate library files. If yes, then find the newest one (keep that one) and remove the old ones.

Analyze Build:
If no duplicate lib files are found then try the "Analyze last build" option. If that does not find anything either then it's an error the tool does not recognize or you are exporting as an Android Studio project. Android Studio project exports are not supported since Unity has no access to the logs produced in Android Studio (it's a separate program). In that case please try to build directly from Unity instead.

If it finds something then the reason is probably a conflicting gradle dependency. Most likely that's caused by some third party asset (Advertisement SDKs are a common culprit). Try disabling each third party asset and make a new build. Do that until the error is gone. Once you know which one causes the problem check if they are modifying your gradle template imports and resolve any conflicting imports. The External Dependency Manager might help you there (in case you have not yet tried it).

Please understand that the tool is no auto-fix solution. What it does is try to get you the info you need to solve the problem. You still have to resolve the conflicts yourself as it's just impossible to know all the library combinations.

I hope this helped you with your problem. If you need more info regarding the tool please don't hesitate to ask.

1 Like