Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

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

Discussion in 'Assets and Asset Store' started by _geo__, May 25, 2022.

  1. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    667
    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
    https://assetstore.unity.com/packages/slug/222357

    Forum_Screenshot1.png
    1) Analyze the errors after the build and gain insights:

    Forum_Analyzer.png


    2) List duplicate libraries before the build.

    Forum_Duplicates.png


    3) Find all libraries in the project.

    Fourm_AllLibs.png
     
    Last edited: Sep 14, 2022
  2. UnitySombra

    UnitySombra

    Joined:
    Sep 2, 2017
    Posts:
    3
    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?
     
  3. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    667
    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.
     
    Last edited: Dec 2, 2022 at 11:40 PM