Here’s a gist of files. Updated to remove any of our game’s info.
I’m probably missing a few things, hopefully this will help in some way until a full tutorial with proof of example test (published in store) can be created and written by myself or another.
NOTE: This was developed with Cocos2dx 2.2.x so there are no guarantees it will work at all with 3.x. I’ll do the tutorial to example test app when I get time with 3.x for both our game’s update as well as hopefully others like yourself.
To make things easier we put all assets (png, wav, ogg, plist, etc) into the expansion file so that it could specify single directory for looking up resources. However, I think with the 3.x asset management through file paths search order could be used instead. Also, expansion files are disabled on Amazon and any other Android platforms. Hopefully I can find time to create an empty game project and upload to google play for full testing along with a tutorial.
Also you need to import three of google’s libraries.
- APK Expansion Zip Library
- Downloader Library
- Licensing Library
Resources
api docs
http://developer.android.com/google/play/expansion-files.html
adding licensing
http://developer.android.com/google/play/licensing/adding-licensing.html
upload w/out exp file first
https://support.google.com/googleplay/android-developer/answer/2481797?hl=en
Files and changes description
FileUtils.cpp: changed to use zip file and obb path if using extension files.
FileUtilsAndroid.cpp: changed to use zip file and obb path if using extension files.
Cocos2dxActivity.java: enable support for using expansion files and using new inits in the helper classes
Cocos2dxGLSurfaceView.java: Nothing needed here. I think the patch file showed changes to onPause/onResume in this class.
Cocos2dxHelper.java: setting the nativeAPKPath here and flag for using exp. files or not
Cocos2dxMusic.java: stream music using native APK zip
Cocos2dxSound.java: play audio using native APK zip
GameActivity.java: The meat of the game’s code changes. Interfacing with the changes to Cocos2dxActivity for delayed init is first methods. Last section of methods is where the downloading expansion files occurs. It’s kinda a mess, but implements the various callback methods to receive progress updates on the expansion file download status.
GameDownloadReceiver.java: pretty much Google’s version
GameDownloadService.java: pretty much Google’s version, just replace BASE64_PUBLIC_KEY_GAME data as well as SALT
GameLib.java: small class to use between Google, Amazon, Samsung, and DRM-Free versions