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. Dismiss Notice

Tips on reducing APK size

Discussion in 'Android' started by kk93, Oct 2, 2014.

  1. kk93

    kk93

    Joined:
    Jan 17, 2014
    Posts:
    55
    Hello,

    My game is currently ~104 mb (apk and expansion). I am hoping to reduce the size of the game so that people won't get the "Are you sure you don't want to download this through wifi" pop-up. Now, I've heard that for Apple, that threashold is 100mb, so I sort of assume that same is the case for Google Play (please correct me otherwise).

    Anyways, I've heard that removing assets that are not in use wont do anything because Unity handles that for me. So, what are some other common methodology used to reduce the size of the game?

    Thanks!
     
  2. DalerHakimov

    DalerHakimov

    Joined:
    Mar 14, 2014
    Posts:
    302
    For Google the size of apk should be 50mb max atm. -> http://developer.android.com/google/play/expansion-files.html
    The rest should be inside the expansion file. If you want to reduce the size of your game and doesn't want to use expansion files, then probably u should work on your graphics and try to reduce them... there is not much that unity could do for you (except the expansion file)...
     
  3. kk93

    kk93

    Joined:
    Jan 17, 2014
    Posts:
    55
    So... like i said, my game is 104 mb for both apk and expansion. my apk is 29mb.

    does the pop-up that says that i should download an app via wifi show up if there is an expansion file? because honestly thats what i am concerned with
     
  4. DalerHakimov

    DalerHakimov

    Joined:
    Mar 14, 2014
    Posts:
    302
    Yeah it will show that pop-up. And if user wants he can download it via wifi or the regular mobile data.. Its up to user.
     
  5. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
    What game are you making that is that large for mobile? I feel like I put quite a bit of detailed models etc in my games and they aren't above 30MB total even.
     
  6. kk93

    kk93

    Joined:
    Jan 17, 2014
    Posts:
    55
    So, funny story, I compressed couple audio files and the logo, and now the total size is less that 50mb, which should be good enough.

    anyways, thx for the responses guys
     
  7. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
    If you are using any asset store stuff I would delete "examples" comes with them & double check for "resources" folders...
     
  8. kk93

    kk93

    Joined:
    Jan 17, 2014
    Posts:
    55
    I think that unity automatically removes those if the scene where those assets are used are not in the game. At least that's what I've been hearing.
     
  9. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
    That saved you ~20MB...? 2 audio files and your logo? Wowza
     
  10. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
    For normal assets, that's true. But the contents of "resources" folder will be included to the build even if those are not referenced in the scene... So if you have some stuff in "Assets/someplugin/examples/resources/" those will be in there...
     
  11. kk93

    kk93

    Joined:
    Jan 17, 2014
    Posts:
    55
    it was about 5 music loops, 30ish sound effects and couple logos (splash screen and icon). Also, it saved me over 50mb.

    Yeah, I am shocked too
     
  12. kk93

    kk93

    Joined:
    Jan 17, 2014
    Posts:
    55
    hmm, looks like i can cut down some more. thank you very much!
     
  13. nburlock

    nburlock

    Joined:
    Apr 11, 2013
    Posts:
    65
    I use a cheap asset called Build Report Tool which lists everything that ends up in your app. It's really good for spotting stuff that unexpectedly large or stuff that should be removed, such as sample assets

    https://www.assetstore.unity3d.com/en/#!/content/8162
     
  14. ugaonkarn09

    ugaonkarn09

    Joined:
    Aug 21, 2015
    Posts:
    1
    i don't know if it still helps your or you already know it but i just found out that if you go to build setings and select the device filter to ARMv7 you can save 10mb of space. i just did it and i am surprised by the output Size. try that also might help. but i don't know what the consequences of that will i havn't tested it yet.. hope it helps..
     
  15. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
    There are two types of Android devices, ARM and x86. When building a FAT build, it can run on both types. There are not that many x86 Android devices, but unless you don't care or really need the extra space, you should use FAT to get the most devices.
     
  16. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
    All store-bought x86 Android devices can run ARMv7 binaries via libhoudini. FAT binary in Android situation only makes the game run faster in x86 Android devices since game already contains x86 optimized binary.
    https://commonsware.com/blog/2013/11/21/libhoudini-what-it-means-for-developers.html

    And Android also supports MIPS CPU architecture so x86/x86-64 and ARM aren't the only ones. Unity doesn't support MIPS, and number of MIPS devices is very low, but it still exists :cool:
    http://developer.android.com/ndk/guides/mips.html
     
  17. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
    Good points.

    Depending on your game though, I think it would be silly to try and have the x86 devices run the ARM binaries, because it will just eat too much performance (at least in my performance intensive games experience).
     
  18. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    294
    I build two separate APKs with a custom build script, one ARM and one x86. Then I upload both to Play Store, which serves the correct APK depending on the user device (assuming x86 builds have higher version codes, otherwise they'd always get the ARM build since they are compatible with those too, as said).
     
  19. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
    So you do something like this?:

    Game v1.0:
    ARM = 10
    X86 = 101

    Game v1.1:
    ARM = 11
    X86 = 111

    Game v1.2:
    ARM = 12
    X86 = 121

    Edit: Maybe it won't let you do that, because once you use 101, even the ARM version has to be higher than that? I was just trying to think of a good way to correspond game version with the version number.
     
  20. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    294
    Yes I do that, except I use 10000 as the difference. It works fine, bit of manual management to maintain two APKs in the Play Store dev.console but not a biggie. :)

    EDIT: Actually not exactly like that, I just increase the version code for each build. You could make it correspond with the version number, I guess, but I didn't bother with that.
     
  21. grell72

    grell72

    Joined:
    Mar 27, 2016
    Posts:
    2
    To be honest, the size is not that big though. There are many famous game apps over 100mb. Mostly are vidoe and audio files.
     
    Last edited: Apr 6, 2016