Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Official Making Android Symbols Package smaller

Discussion in 'Android' started by Tomas1856, May 14, 2021.

  1. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    Hi,

    since there are a lot of posts complaining about Android Symbols package being too big, here are the small instructions on how to make them smaller.

    Note: In 2021.1, there's an improvement in regards to symbol packaging, where you can select to only zip Public Symbols, also the symbols will have .so extension

    There are two reasons why symbol package is so big in Unity 2020 or lower:
    • The zip is created with Store method (meaning no compression is happening)
    • Both public and debugging symbols are included
    • While not affecting the size, the public symbols have .sym.so extension, while Google wants .so extension.
    To make symbol package smaller:

    • Extract symbol zip package
    • Delete all files ending with .dbg.so extension
    • Rename .sym.so extension to so. For ex. libunity.sym.so should become libunity.so
    • Rezip

    Alternatively, I attached a helper script to this post, place it in Assets/Editor folder. Then from menu pick Android Symbols->Shrink, it will perform the steps I described above automatically.

    Hope that helps
     

    Attached Files:

  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
    Very handy script, thanks :)
     
  3. poliman

    poliman

    Joined:
    Feb 5, 2015
    Posts:
    29
    Great job, from 1,5GB to 190MB Thx
     
    Tomas1856 likes this.
  4. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,114
    Hi @Tomas1856. Can u provide me the script that integrate this AndroidSymbolShrinker into platform android package? As long as I choose Public create symbols it will go through AndroidSymbolShrinker as last step. Btw is there any plan to backport this feature to 2020.3 LTS that will work just like 2021.1?

    upload_2021-6-15_23-15-35.png
     
  5. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    No, there are no plans to backport this change to 2020.3. Also, in this case, if you want to apply this as post processing step, you would need to do it yourself.

    Alternatively, you can query Unity support - https://unity.com/products/unity-core-support

    Hopefully that helps.
     
    Last edited: Jun 15, 2021
  6. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,114
    @Tomas1856 Can I know what is blocking it from backport this change to 2020.3? Is that something big changes related to android gradle?
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    Only bug fixes or critical changes are usually backported, in this case, this is considered an improvement, thus it doesn't qualify for backporting.
     
  8. clamum

    clamum

    Joined:
    May 14, 2017
    Posts:
    61
    Where is the Assets\Editor folder? In the "Program Files\Unity" folder somewhere? In my project folder? I of course have an "Assets" folder in my project but no "Editor" folder under that. Thanks!
     
  9. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    In your Unity project, if it's not present, just create one
     
    clamum likes this.
  10. ryanroy837

    ryanroy837

    Joined:
    Jan 20, 2022
    Posts:
    2
    Thanks For Valuable insight
     
  11. ongtypc

    ongtypc

    Joined:
    Apr 16, 2019
    Posts:
    4
    I have the exact same needs and I made a PostProcessor script that works on my 2019.4 editor. It's just an extension of @Tomas1856 's script (thank you btw!).
     

    Attached Files:

    PanicEnsues and optimise like this.
  12. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    390
    I use the script here to shrink our symbols, and it's still bigger than Google Play's limit. And I found the difference between the size of libil2cpp.dbg.so and libil2cpp.sym.so are not so large. For our project, they are 719MB and 714MB (for arm64).

    According to the documentation(https://docs.unity3d.com/2020.3/Documentation/Manual/android-symbols.html), Unity has used '--strip-debug' to make the file smaller. But I tried it myself:
    The generated files are 131MB and 126MB.

    Since our game has not published, I can't test whether my generated symbols are working.

    @Tomas1856 Can you confirm Unity generate expected symbol file with --strip-debug? (We are using Unity 2020.3.26)
     
  13. AtilganSak

    AtilganSak

    Joined:
    Oct 20, 2021
    Posts:
    4
    This script not working on Macos!! Is there any alternative for macos?
     
  14. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    What exactly is not working? Alternative - would be to switch to 2021 LTS, where new symbols creation functionality makes this script obsolete.
     
  15. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Can confirm, I am also using macOS, I cannot select the zip file. Upgrading to Unity 2021 is definitely not an option...

    Edit:
    I have to change the targeted extension from "*.zip" to "zip". And then change the name of the compression tool from "7z" to ''7za'. It works after fixing these two.
     
    Last edited: May 18, 2022
    Moran_Comunix likes this.
  16. Elapotp

    Elapotp

    Joined:
    May 14, 2014
    Posts:
    98
  17. dmaisy

    dmaisy

    Joined:
    Sep 1, 2018
    Posts:
    3
    Funciono perfecto.
     
  18. Moran_Comunix

    Moran_Comunix

    Joined:
    May 2, 2020
    Posts:
    3
    Worked for me, thank you!

     
  19. Moran_Comunix

    Moran_Comunix

    Joined:
    May 2, 2020
    Posts:
    3
    Worked like a charm, thanks!

     
  20. AntonPetrov

    AntonPetrov

    Joined:
    Dec 27, 2013
    Posts:
    63
    While official docs from 2020.3 say "Unity uses the
    --strip-debug
    parameter to create public symbols that remove more in-depth debug information." my non-debug
    .sym.so
    file is the same size as
    .dbg.so
    file being produced (1GB+ each)

    After making
    --strip-debug
    by hand as in here https://support.google.com/googleplay/android-developer/answer/9848633?hl=en#zippy=,native-generate-a-debug-symbols-file I receive 190MB files.

    I am pretty sure this is a 2020.3 bug.

    UPDATE:

    In the end I have implemented my own script which repacks symbols.zip and applies
    objcopy --strip-debug
    . Initial size of 3 GB reduced to 100 MB symbols.zip
     
    Last edited: Dec 7, 2023
  21. BjoUnity3d

    BjoUnity3d

    Joined:
    Jul 24, 2012
    Posts:
    59
    To fix the original script from Tomas for MacOS I added the a to 7za on this line
    Code (CSharp):
    1.         var zipFileName = Path.GetFullPath(Path.Combine(EditorApplication.applicationContentsPath, "Tools", "7za"));
    2.