Just create a main.VERSIONCODE.PACKAGENAME.obb file. Put it into /sdcard/Android/obb/packageName and it will be used instead of the assets folder. This file should be installed while installing from the PlayStore. Currently I found no build-in download routine, if the user deleted this file manually.
Another issue is, that you always have to update (or rename) your OBB file with the APK. This could also be improved, because the user has always to download the big package in case of an update. There is now way to use OBB files with lower versionCodes, yet.
The cocos team can’t fix it, because they have no access to the PlayStore. So the community (we) have to build a good working solution in the future.
You should consider OBB only If you’re unable to host your excess data (>100MB) elsewhere on your own whether through another service or your own server and have your game use the various asset management classes in cocos2d-x.
It requires extra work during publishing, doesn’t allow easy modification like simple changing a manifest file on your server would, etc. It may be slightly easier in the short-term to set up since you don’t have to host anything, but in the long-term it will likely be more of a pain than not.
Also with your own hosted data it would be fully cross-platform. Otherwise on iOS you’ll need to also manage and setup the workflow to use Apple’s On-Demand Resource capabilities.
It’s mostly a personal preference, of course, and YMMV
2c
@smitpatel88, there are two options exist to work with OBB file:
native OBB created by jobb tool (not encrypted, because jobb tool is buggy)
OBB/ZIP file (when obb file is just a ZIP archive renamed to be a file with .obb extension)
Cocos expects that you will work with OBB/ZIP. It’s not intended to support native OBB format. But it’s still possible to work with it. Native OBB mounts into the Android file system so it’s possible then work with it using POSIX fopen, fwrite, fread functions. Also the native OBB format has no option to compress your data inside it.
Hey @mars3142, it looks like we are at the point when we need this feature when Cocos app could work with the same old version of OBB file after updated .apk was uploaded to Google Play and VersionCode was increased.
We see that now Cocos uses current .apk VersionCode to compose a name for .obb file that makes impossible to work with the same version of .obb file after .apk was updated. I offer to discuss possible best options how to implement this feature. Probably it’s better to create a new topic for that?
As I wrote “it will be used instead of the assets folder” (or added - can’t remember it). So you can access your files (within the zip) like files in your asset folder. No need to do special voodoo, because cocos does everything for you.
@jugnu@mars3142
I am testing one game with obb file
Now problem is in few devices its not running, its crashing. Actually i putted log at java side and it says obb file not exist. Also in one device its running fine if i put obb file in phone-memory, but in sdcard its crashing.
In Cocos2dxHelper.java i found this line
pathToOBB : /storage/emulated/0/Android/obb/package_name
OBB file name : main.1.package.name.obb
It works in one device but only in phone-memory, if i put into sdcard then its not working.
We tried both install-location:'auto' & install-location:'preferExternal' if that matters.
What’s the Android version? in older versions you need read/write access to the sdcard, this is removed in current versions because the /Android/data and /Android/obb folder are app specific and that’s why it’s a bad idea to block access
Is that right, that your packageName is one time with underscore the the other is with dot? I the obb (main.1.*.obb) file within the pathToOBB? The packageNames should both written the same way (case sensitive and with the same underscores).
We are checking into 5.1, 6.0, 7.0 & 7.1.2
So now everything is working, we were making mistake while copying obb file (some Windows cache memory problem though while transferring through data cable)
Only problem is now that its not working if we put into sdcard, will this be taking care by play store?
Edit:
We had added read/write permission, then its working for internal memory. But still not working for sdcard.
Hello, I got error when upload obb file to google play too .
When I test in my phone , it run but when I upload apk to store and download app to my phone , it crash , black screen . I don’t know what happen , but I think got problems with read obb file . I check in Android/obb , have file obb but maybe app don’t read it. Do you have any solution?
Hi smitpatel88,
I can’t find any solution yet , I comeback with version 3.11.1. In 3.11.1 , my old project is running well. I will try find solution for version 3.16 later. Thank you.
Hi smitpatel88,
Yes, my project up to google store with version 3.11.1 is working with Obb Expansion File .
I follow with topic Android APK Expansion Files with cocos2d-x v3 and this gist by stevetranby https://gist.github.com/stevetranby/3151c541a7ce17cbd9bc to build my expansion obb. And it’s working.
I check java code and cpp code in version 3.16 , it’s simply build file obb and cocos2dx 3.16 do everything with expansion. But up to store , app does not read file obb even when i have find obb in Android/obb .
You can try to test by this step: build your apk , copy your obb file and apk in your device . Setup Apk . I try and get error can’t find file obb look like app does not read it.
Thank for you attention.