Search Unity

How to reduce the android app build size!

Discussion in 'Android' started by UNITY3D_TEAM, Oct 26, 2016.

  1. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
    How to reduce the android app build size!


    right now without any data the empty unity project getting 18mb output file .How to reduce that size around 5mb?
     
  2. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    you can build an apk per processor architecture (e.g: ARM and x86 APKs).

    This removes around ~ 8 - 10 mb from the build.
     
    UNITY3D_TEAM likes this.
  4. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
    any other answers?
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,442
    If you have 'using System;' in some script, it adds 1mb(?) (not tested, but have heard so..)
     
  6. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
    right now i can able to reduce only 10 mb as liortal said .by changing to arm7. but i dont think using system will reduce size.empy scene without script is 19mb right now
     
  7. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
    if u change arm 7 only target format for processor then u get 19-9 mb so =10 total .for a empty project
     
  8. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
    i dont know how to reduce more than that .if any other know let me know.empty scene should take that much size.want to reduce that
     
  9. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    The engine + mono takes a few good mb's.. u cannot drop below that. even for an empty scene (no content).
    You can try to use il2cpp on Android, i haven't used it so i am not sure what is the current size for those builds.

    In il2cpp i believe that they apply stripping for engine code, so that may reduce the unused parts and reduce the overall size.
     
  10. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
  11. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
    ok thanks for all !
     
  12. aklgupta

    aklgupta

    Joined:
    Jun 9, 2014
    Posts:
    29
    Bumped across this while try to reduce the size of a very simple game, currently consuming 24 MB.

    Thanks.. that explains a lot.. But 15MB for mobile platform is a lot I believe, where size matters a lot. Still way better than UE4 I guess.
     
  13. zmirli_6

    zmirli_6

    Joined:
    Mar 15, 2018
    Posts:
    7
    When i run my app size of apk will 21 MB. even i enabled proguard. i use android studio to run project. in project files src folder has 8.62 MB size and lib folder size is 400 KB size. so how i reduce size of .apk file. Actually .apk file is 8 mb before some days with same images but after paypal integration my app size will increases to 21 mb. size of build folder is 127 MB.
     
  14. aklgupta

    aklgupta

    Joined:
    Jun 9, 2014
    Posts:
    29
    I am using Unity 22018.1.7, however, but I remember reading in the release notes, that, iirc, the latest version allow us to chose which default packages to include in the build. I am not sure if they mean what I think they mean, but I believe we can remove the unneeded Unity modules now. Has anyone tested this?
     
  15. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    I tired it. Should just work :)

    upload_2018-11-16_13-54-31.png
     
  16. aklgupta

    aklgupta

    Joined:
    Jun 9, 2014
    Posts:
    29
    That's really great. What was the final size?
    Also, I noticed that you are using 2019.1 Alpha, not the latest f release. But, it is there in 2018.2+, right?
     
  17. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Yes I think it's present in 2018.2 and later.
     
  18. aklgupta

    aklgupta

    Joined:
    Jun 9, 2014
    Posts:
    29
    Great.

    Too sad I tried 2018.2 yesterday, but my project doesn't seem compatible.
    Mostly due to the use of TextMeshPro. T_T
     
  19. NoDumbQuestion

    NoDumbQuestion

    Joined:
    Nov 10, 2017
    Posts:
    186
    For anyone stumble upon this post later, disable unity build-in package did not help reduce file size. It gonna be stripped if you not using it anyway so there is no point disable it.

    And the smallest size I can get with 2018.2 unity default scene with Camera is 6.25MB

    You have to use stripping engine code with:
    - Scripting runtime version: .Net 3.5
    - Script Backend: ILL2CPP
    - Api compatibility level: .Net 2.0 Subset
    For Texture: Use Unity Atlas or sprite packer to reduce texture size
    For Scene: use asset bundle does help compress Scene Size in build
    For Music: lower it from wav to 192kbs MP3
     
    DanielRPixelMan and aklgupta like this.
  20. aklgupta

    aklgupta

    Joined:
    Jun 9, 2014
    Posts:
    29
    Thanks @NoDumbQuestion
    Worth noting

    BTW, doesn't Unity automatically use Atlas for all textures?

    What do you mean by this?
     
  21. NoDumbQuestion

    NoDumbQuestion

    Joined:
    Nov 10, 2017
    Posts:
    186
    @aklgupta
    No, Unity did not magically package all of your sprite, texture into any 2^n square texture to save space.
    That's why we have TexturePacker

    You can compress your .scene with assetbundle to save more space in scene. It like trading loading speed for lighter space.
     
  22. aklgupta

    aklgupta

    Joined:
    Jun 9, 2014
    Posts:
    29
    Oh, thanks. I thought it those so automatically in the newer versions. I remember reading something like that somewhere, can't recall where.
     
  23. Cuttlas-U

    Cuttlas-U

    Joined:
    Apr 11, 2017
    Posts:
    38
    Also dont forgot to Use "Default" Compression method , is u want to reduce the size ..
     
    Propagant likes this.
  24. unity_9460FB1EA99EC1823D00

    unity_9460FB1EA99EC1823D00

    Joined:
    Aug 3, 2021
    Posts:
    12
    I am still wondering how to reduce included DLLs from build size. I have enable stripping level too! . I am also looking for explanation of Total User Assets , how to reduce that one. I am using admob and unity ads plugin no other third-party assets. Another question is, does unused assets have impact on build size if they are present in project???
    upload_2022-6-20_11-29-10.png
     
    DarkCooker likes this.