Android and large APK sizes

Greetings,

I’ve been searching for a solid answer on this, and perhaps someone here can point me in the right direction. We haven’t had the need for it yet, but I worry that eventually our Android binary sizes will go beyond the 100MB limit.

I realize that hitting Split Application Binary in the player settings is an answer, but we have yet to get this process to work once uploaded to Google Play. The app downloads without a hitch, presumably with the OBB as the file size coming down is correct, but I can’t seem to load the OBB file made from Unity.

Is there an official tutorial or method to make this work properly? A quick google search will bring up a series of differing answers on this topic. A lot of the stuff I’ve found so far seems to be a few years out of date at least.

Perhaps, if there is no official Unity 5.5+ method of doing this, how do you handle it?

What do you do when your Android binary exceeds 100MB?

Thanks in advance. ^^

First, you should be checking if you really must exceed the 100MB size. Try looking at the build report to understand what is contributing to this large APK size.

A very simple thing to do is create 2 APKs - one for ARM and one for x86 based devices.
By default, Unity sets this to FAT, which includes both libraries in the APK.

Google Play allows you to upload different APKs for different CPUs, so you can do this and easily reduce around ~ 10 MB from the final APK size.

Apart from this you should check the assets that make it into the build to see if you can cut down from there to further reduce the size.

Lots of games use split loading, it’s sometimes necessary if you have many assets (Angry Birds 2 for example does this, as our own game).

I’m not quite sure why your obb is not loaded correctly. Perhaps there’s something wrong with your implementation for the .obb file loading? Have you tried using Unity’s OBB downloader plugin? We’ve re on Unity 5.4 and it works fine.

This might also help : You don’t need to upload to the Store to test if your obb file is loaded OK. You can do this with ADB and a connected Android device.

  1. Create your split apk, signing with the production key.
  2. Once the files are out, rename your .obb file to
    main..com.yourcompanyname.yourappname.obb. For example:
    main.3.com.rovio.angrybirds2.obb
  3. From a command console with adb access, write

adb shell mkdir /mnt/sdcard/Android/obb/com.yourcompanyname.yourappname
adb push “main..com.yourcompanyname.yourappname.obb” /mnt/sdcard/Android/obb/com.yourcompanyname.yourappname/

This creates the appropriate folder and pushes your obb file to the destination folder.
4. Copy your (smaller) Apk to the device, and launch the app.

If your implementation is correct, the apk will load the obb file.

1 Like

Thank you everyone for your replies. It would seem as though the difficulty we’re having isn’t with the acquisition of the OBB file itself, but the loading thereof after the user as successfully pulled down our binary. Is the Unity’s OBB Downloader necessary to load the OBB file after its been pulled down? I’m somewhat skeptical of a plugin dependency that hasn’t been updated since Unity v4.6.

@jjustind It’s not necessary to use the OBB downloader plugin per se, you can make your own implementation. But you have to have some way to talk to the system and find out how to retrieve the file. You can take a look at Google’s official documentation and adjust their Downloader Library as needed to work with your project. AFAIK this is what Unity’s plugin does, but I think with an older version of the Downloader Library.

You can have a look at the Unity plugin implementation and adjust it if it doesn’t suit your needs. Full source code is provided so you can rebuild the library if you wanted.