[RESOLVED]Can i load resource from .obb file directly

[RESOLVED]Can i load resource from .obb file directly


Hi ,
i have used expansion file (.obb) in my android project, so i changed my search path like this:

 std::vector<std::string> resDirOrders;

But now i have errors :

cocos2d: SpriteFrameCache: couldn't load texture file. File not found splashscreen.pvr.ccz
: Assert failed: Invalid spriteFrameName: splashscreen.png

So i would like to know if i can load resource from .obb file directly ?


Cocos2dx 3 and OBB on android

You can’t.

There might be two options.

  1. Use non-encrypted obb file and mount it.
  2. Unzip obb file to memory at runtime if use encrypted obb.


i used non-encrypted obb, but i didn’t mount it , should i mount it ?



You should mount obb if you use directly with FileUtils.
But mounted obb path is not the same as obb path.
You should obtain mounted path.



Thanks @hzlov, i have mounted the obb file and i got a path like this /mnt/obb/880f5ef6a6885d1b8937f9625be73850;
but how to get the final path to my assets ( myAssets folder in the .obb file)? i read that we should ignore subfolder?


i have this message:


But when i browse to this directory i find it empty !

Please help me .


You may access by /mnt/obb/880f5ef6a6885d1b8937f9625be73850/myAssets/...

But mounting obb would needs some time to be mounted successfully.


Thanks, but why when i browse to this directory i find it empty


Did you add a permission to manifest.xml?

<manifest ...>
    <!-- Required to read and write the expansion files on shared storage -->
        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


Did you mean browsing by another file app?

I’m not sure but it may be because of permission not to allow read by another app.


Yes, i did


thanks @hzlov, I used another activity which extends from android.app.Activity for checking the availability of the expansion file, if the file exist, it will mount it and call the Appactivity which extends Cocos2dxActivity, what do you think about that ?


I think that is formal approach.


Yes, you’re right


hzlov i use non-encryped obb file and mount it …
main obb file create mac -r0 option
but OnObbStateChangeListener() call state ERR0R_INTERNAL
Obb file problem? or some different problem?


I have that error too, in android 4.4.4, did you fixed it ? plz share with me