Android obb expansion file

Hello,

I am using cocos2d-x 3.17.1 with C++.
I want use an obb expansion on Android for the Resources folder.
I have zip “Resources” folder and I have rename it to main.1.com.xxxx.app.obb.
I have put this file on Android/obb/com.xxxx.app/main.1.com.xxxx.app.obb
I have remove the Resources folder of my project.

I run the game and the game crash, the error is this:
cocos2d-x debug info: cocos2d: fullPathForFilename: No file found at res/close_button.png. Possible missing file.

I have use the jobb command to package the Resources folder with the same result.

Help please.

Does FileUtils successfully reach out to obb file directory? And I thinks you should unpack obb file before accessing.

Thanks for your response.

FileUtils read successfully the directory and the file.
I have modify Cocos2dxHelper.java file to put some log:
https://imgur.com/ivRB7M9

This is the log:
====pathToOBB: /storage/emulated/0/Android/obb/com.xxxx.app
====Environment.getExternalStorageDirectory().getAbsolutePath(): /storage/emulated/0
====name: main.1.com.xxxx.app.obb
====fullPathToOBB: /storage/emulated/0/Android/obb/com.xxxx.app/main.1.com.xxxx.app.obb
====Exist: /storage/emulated/0/Android/obb/com.xxxx.app/main.1.com.xxxx.app.obb

But Cocos2D-X does not read the resources, the error is:
cocos2d-x debug info: cocos2d: fullPathForFilename: No file found at res/close_button.png. Possible missing file.

Thank you so much.

I think you need to get read storage permission at runtime for this.
Read here : https://developer.android.com/google/play/expansion-files

Thanks for your response.
I have read the documentation but I don’t know how to integrate on Cocos2D-X project.
In other posts I have read that Coco2D-X manages the obb files automatically (for example: How to use obb extension file?)

Do you have some advice?

Thanks!

Yes, but that is for older version of Android (below 6), after that Android made compulsory to ask permission on runtime.

Do you know about JNI call? Basically you need to code at java side and handle it from your game cpp through JNI.

@smitpatel88
I’m testing on Android 5, but thank you for the response.

Maybe @slackmoehrle can give me some advice?
Thank you very much.

Then it should work. Did you add READ_EXTERNAL_STORAGE permission into manifest file?

Yes, I have included READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE.
How do you compress Resources directory? jobb or zip? Do yo compress Resources directory or the content of Resources folder?

Thank you!

I use jobb, and Compress content of resources folder.
If you can open your obb file into 7zip, then everything is correct.
I had used this 2yr back.
.\jobb-26.0.0-dev.jar -d C:\projects\GameName\Resources -o main.1.com.xxxx.app.obb -pn com.xxxx.app -pv 1

1 Like

Hi,

To test the obb file before publish on Google Play, do you put it in Android/obb/com.xxxx.app/main.1.com.xxxx.app.obb?
The game doesn’t find the assets :frowning:

Thank you very much.

Hello,

I still have problems with obb files… Somebody could help me please?

Thanks.