cancel
Showing results for 
Search instead for 
Did you mean: 

Big (up to 4GB) Expansion File Support... how?

robertogeek
Protege
Hi,
Some time ago, Oculus released a new tech note about Expansion File Suppor for GEAR VR (link) announcing that big (up to 4GB)  expansion file support was allowed. 
My question is how to create such a big .obb files using Unity (2017.1.0p2), because it is throwing the following error from aapt.exe:

> C:\Program Files (x86)\Android\android-sdk\build-tools\27.0.2\aapt.exe package -v -f -F rawobb.ap_ -A rawobb -0 "" --ignore-assets "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
stderr[  Unable to add 'rawobb\MenuMusic.tbe': Zip add failed (-2147483648)
ERROR: unable to process assets while packaging 'rawobb.ap_'
ERROR: packaging of 'rawobb.ap_' failed

We have been searching a lot about this, and "forums" said that this is a limitation of 2 GB of Android Extension File system (link). So, because of that, aapt.exe is not able to create expansions files bigger than 2 GB. We have tried with several build-tools versions, and always throws the same error. 

Because of that I would like to ask you about how could we proceed to create such a big expansions files.

Many thanks.
9 REPLIES 9

oculus_gabor
Protege
Hey,

OBB files are just opaque binary blobs. Meaning, any file with a .obb extension is valid. I've only had to use OBB files on native projects with big video files in the past. For those, it was just a matter of changing the .mp4 extension to .obb, and everything kind of works out of the box. 

The version of android that's found on phones supports two OBB files, up to 2GB each, totaling 4GB. This is different from what we support. I wouldn't be surprised if tools like aapt had a hard coded limit at 2GB.  Unfortunately, working around this limit is not going to be easy. 

What i would do is package additional content in unity asset bundles. Put all the asset bundles in a zip file (Which has a convenient limit of 4GB anyway), then change the extension of the file from .zip to .obb. You then need to write some application logic to either stream asset bundles out of the obb file and load them into unity, or to unzip the obb file, then just load assets off the disk. I suggest streaming over unzipping to save disk space.

From what i understand this is the best way to make things work. I could be wrong and there might be a cleaner solution.

robertogeek
Protege


Hey,

OBB files are just opaque binary blobs. Meaning, any file with a .obb extension is valid. I've only had to use OBB files on native projects with big video files in the past. For those, it was just a matter of changing the .mp4 extension to .obb, and everything kind of works out of the box. 

The version of android that's found on phones supports two OBB files, up to 2GB each, totaling 4GB. This is different from what we support. I wouldn't be surprised if tools like aapt had a hard coded limit at 2GB.  Unfortunately, working around this limit is not going to be easy. 

What i would do is package additional content in unity asset bundles. Put all the asset bundles in a zip file (Which has a convenient limit of 4GB anyway), then change the extension of the file from .zip to .obb. You then need to write some application logic to either stream asset bundles out of the obb file and load them into unity, or to unzip the obb file, then just load assets off the disk. I suggest streaming over unzipping to save disk space.

From what i understand this is the best way to make things work. I could be wrong and there might be a cleaner solution.


Thank you very much @oculus_gabor for your response.
We are following your instructions; but the issue that we are having is that I am not able to make Unity recognise that "modified manually" .obb file. Do you have any clue about that? Thanks again!

rosebud_the_sle
Expert Protege
The basic idea here is to not use Unity's "split application binary" option at all, but instead put some (or all) of your scenes into an asset bundle, build that every time you build the apk, and upload the two together, passing the bundle as the obb.  At runtime you can load the bundle from the spot where the store deposits it and then continue execution as normal with no further code changes.  This approach lets you increase the size of the bundle up to 4 GB.

Here's the Unity docs about creating bundles: https://docs.unity3d.com/Manual/AssetBundles-Workflow.html.  It's pretty easy to take all of your scenes and mark them as being in a bundle, then use AssetBundle.LoadFromFile (https://docs.unity3d.com/ScriptReference/AssetBundle.LoadFromFile.html) to load the bundle at startup.  If you use SceneManager to load scenes this will automatically start pulling them out of the bundle and you shouldn't need to change any code.

The asset bundle that you submit to us gets renamed and deposited at a reliable location, as documented here: https://developer.oculus.com/blog/tech-note-expansion-file-support-for-gear-vr-beta/

The only trick here is that the file name of the asset bundle will include the version code (what Unity calls a "bundle version code"), which Unity doesn't make available to you in a simple way at runtime.  There are various solutions to this--my preferred method is to use AndroidJNIObject to pull it out of Java APIs from C#.  But there are plugins and other things you can grab that do this as well.

robertogeek
Protege
Thanks @chrispruett for your response
chrispruett said:
  • asset bundle, build that every time you build the apk, and upload the two together, passing the bundle as the obb.  
How could I pass the bundle as the obb? Simply zipping it with the store option? Or another method? Thanks!

iphonedev
Honored Guest
If you select developed and Run, the APK and OBB files are installed on your mobile device by Unity. If you select build and
want to install the app manually using the ADB utility, you must first
install the APK and then copy the OBB into the correct location on your
device. You can refer to the expansion files part of the Android Developer documentation for more detail.

robertogeek
Protege
Of course @iphonedev , that's easy. But I was asking about convertith the asset bundle into an obb file.

Adriano_perez
Honored Guest
Hi, @iphonedev  @FutureLighthouse we have the same problem

EtienneArchamba
Explorer
Hello, I'll post this in as it answers the previous questions : https://developer.oculus.com/blog/tech-note-expansion-files-with-unity/

KeithMyers
Honored Guest
Hello, I tried to follow what chrispruett said to do but I cannot get my app to load the bundle.  It's pretty confusing - I created the bundle assets in a folder and I have my load begin when start is called, which is attached to a game object in a holding scene, but still no joy and my asset bundle is not loaded.  Any ideas?  Thanksfjssvhpwltre.png