Cocos2dx Android OBB

Hello,
I am creating a game on Cocos2dx, but its apk size is crossing 150MB.
I want to add file expansion OBB from android studio.

Do anyone have link how to do that for cocos2dx project…

Thank you.

In cocos2d-x (i’ve tested it in 3.16) you only need to put the obb file into the correct folder and remove the Resource folder linking to assets. With that everything work fine.

Android Studio can’t copy the obb while testing, so you have to do it by yourself. I prefer it on the terminal with the command adb push main.X.packageName.obb /sdcard/Android/obb/packageName/ (X -> versionCode and packageName from your game).

1 Like

Thank you @mars3142 for your reply.
I am trying to do in android studio, i am adding codes from https://gist.github.com/moust/7990925 link…

But while testing when i am putting resource file or .obb file into device OBB folder application is not able to find that file and while opening its crashing.

And while uploading apk with obb file to google play, its not downloading .obb file…

Could you please tel me proper way how can i implement it.

Thank you.

What’s your cocos version? And what’s the packageName, versionCode and OBB-filename?

The PlayStore should download the OBB file, if you install the game from there. If you sideload the APK onto the device you need to download the OBB by yourself.

My cocos version is 3.16, packageName is “com.juegostudios.testIAP”, versionCode is 1,
OBB-file name is “main.1.com.juegostudios.testIAP.obb”.

If you copy this file (and it’s a normal ZIP file) manually, cocos 3.16 should be handle it. I’m sure it worked, because I did it for my project as well, but I didn’t test the PlayStore upload yet. Only manual copy to sdcard.

Do you have Android M (or higher). Does the app have checked the runtime read permission? I read that API 21 to API 23 need this for obb files.

I zipped the resource file and changed its name from resources.zip to main.1.com.juegostudios.testIAP.obb. and copied the folder to Android->obb->packageName(com.juegostudios.testIAP) folder.

and removed resources folder from the Game.

But when i am debugging Game to device api-21 its not finding main.1.com.juegostudios.testIAP.obb, and crashing…

Do i need to do anything else…???

Runtime Permission? What’s the error message in the logcat?

n D: cocos2d: fullPathForFilename: No file found at CommonBG/login_bg.jpg. Possible missing file.
com.juego.duckontherun D: Assert failed: Argument must be non-nil
com.juego.duckontherun E: /Volumes/Workspace/Alok_PC/DuckOnTheRun/DuckOnTheRun/cocos2d/cocos/./2d/CCNode.cpp function:addChild line:1011
com.juego.duckontherun A: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 9223 (GLThread 1546)

This is the error i am getting

Don’t use upper case filenames. It’s best to use only lower case. Maybe this is the issue.

What’s the structure in the OBB? The file has to be at /CommonBG/ (without resources or something in front of it).

I think its same because i just zipped the resources folder and changed its name to .obb…

Do i need to create a folder and put the resources folder into new folder and change the name of new folder…???

I uploded apk or obb file on google play store, its downloading it, but while starting the app…
02-13 19:36:21.506 4061-4084/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 4084 (GLThread 1413)
02-13 19:36:21.545 1204-1236/? D/PMS: releaseHCC(4da2149): CPU_MIN_NUM ActivityManager-MultiCore-Num 0x8000 null
02-13 19:36:21.546 1204-1236/? D/PMS: releaseHCC(e7a9a4e): CPU_MIN_FREQ ActivityManager-MultiCore-Freq 0x2000 null
02-13 19:36:21.547 2832-2847/? E/MP-Decision: Update arg 1
02-13 19:36:21.558 418-418/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-13 19:36:21.558 418-418/? A/DEBUG: Build fingerprint: ‘htc/htc_asia_india/htc_a5dwg:6.0/MRA58K/707324.1:user/release-keys’
02-13 19:36:21.558 418-418/? A/DEBUG: Revision: ‘0’
02-13 19:36:21.558 418-418/? A/DEBUG: ABI: ‘arm’
02-13 19:36:21.559 418-418/? A/DEBUG: pid: 4061, tid: 4084, name: GLThread 1413 >>> com.juegostudios.testIAP <<<
02-13 19:36:21.559 418-418/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
02-13 19:36:21.580 418-418/? A/DEBUG: r0 b93ad4d8 r1 00000000 r2 00000000 r3 a0cb820c
02-13 19:36:21.580 418-418/? A/DEBUG: r4 a05a7e5c r5 b93ad4d8 r6 00000000 r7 a05a7e54
02-13 19:36:21.580 418-418/? A/DEBUG: r8 b93ad4d8 r9 b8eff818 sl a05a7ef0 fp b8eff818
02-13 19:36:21.581 418-418/? A/DEBUG: ip b6ccf5d8 sp a05a7e28 lr a0b369bf pc a0cb8214 cpsr 40070010
02-13 19:36:21.600 418-418/? A/DEBUG: backtrace:
02-13 19:36:21.600 418-418/? A/DEBUG: #00 pc 003fc214 /data/app/com.juegostudios.testIAP-1/lib/arm/libMyGame.so (cocos2d::Node::addChild(cocos2d::Node*)+8)
02-13 19:36:21.600 418-418/? A/DEBUG: #01 pc 0027a9bd /data/app/com.juegostudios.testIAP-1/lib/arm/libMyGame.so (DRPrivacyPolicy::addBackgroundImage()+68)
02-13 19:36:21.600 418-418/? A/DEBUG: #02 pc 0027ba33 /data/app/com.juegostudios.testIAP-1/lib/arm/libMyGame.so (DRPrivacyPolicy::onEnter()+10)
02-13 19:36:21.600 418-418/? A/DEBUG: #03 pc 003fd100 /data/app/com.juegostudios.testIAP-1/lib/arm/libMyGame.so (cocos2d::Node::onEnter()+136)
02-13 19:36:21.600 418-418/? A/DEBUG: #04 pc 0046978c /data/app/com.juegostudios.testIAP-1/lib/arm/libMyGame.so (cocos2d::Director::setNextScene()+184)
02-13 19:36:21.601 418-418/? A/DEBUG: #05 pc 0046d358 /data/app/com.juegostudios.testIAP-1/lib/arm/libMyGame.so (cocos2d::Director::drawScene()+88)
02-13 19:36:21.601 418-418/? A/DEBUG: #06 pc 0046d4a0 /data/app/com.juegostudios.testIAP-1/lib/arm/libMyGame.so (cocos2d::Director::mainLoop()+40)
02-13 19:36:21.601 418-418/? A/DEBUG: #07 pc 000eaf59 /system/lib/libart.so (art_quick_generic_jni_trampoline+40)
02-13 19:36:21.601 418-418/? A/DEBUG: #08 pc 000e6861 /system/lib/libart.so (art_quick_invoke_stub_internal+64)
02-13 19:36:21.601 418-418/? A/DEBUG: #09 pc 00406263 /system/lib/libart.so (art_quick_invoke_static_stub+170)
02-13 19:36:21.601 418-418/? A/DEBUG: #10 pc 000ecebf /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+290)
02-13 19:36:21.601 418-418/? A/DEBUG: #11 pc 003a5cc3 /system/lib/libart.so (artInterpreterToCompiledCodeBridge+138)
02-13 19:36:21.601 418-418/? A/DEBUG: #12 pc 002091b9 /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+336)
02-13 19:36:21.602 418-418/? A/DEBUG: #13 pc 000c0c9d /system/lib/libart.so (art::JValue art::interpreter::ExecuteGotoImpl<false, false>(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue)+26164)
02-13 19:36:21.602 418-418/? A/DEBUG: #14 pc 001ee769 /system/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*)+80)
02-13 19:36:21.602 418-418/? A/DEBUG: #15 pc 00403b5d /system/lib/libart.so (artQuickToInterpreterBridge+548)
02-13 19:36:21.602 418-418/? A/DEBUG: #16 pc 000eafd3 /system/lib/libart.so (art_quick_to_interpreter_bridge+34)
02-13 19:36:21.602 418-418/? A/DEBUG: #17 pc 02ff3441 /system/framework/arm/boot.oat (offset 0x2262000)
02-13 19:36:22.156 1427-1427/? D/wpa_supplicant: wlan0: Control interface command ‘SIGNAL_POLL’
02-13 19:36:22.165 1427-1427/? I/wpa_supplicant: environment dirty rate=7 [13][1][0]
02-13 19:36:22.165 1204-1394/? D/WifiStateMachine: fetchRssiLinkSpeedAndFrequencyNative abnormalRssiCnt = 0
02-13 19:36:22.165 1204-1394/? D/WifiStateMachine: fetchRssiLinkSpeedAndFrequencyNative rssi=-77 linkspeed=21 freq=2437
02-13 19:36:22.165 1204-1394/? E/HtcWifiRssiMonitor: newrssi =-77 , oldRssi= -76
02-13 19:36:22.166 1204-1397/? D/ConnectivityService: updateNetworkScore for NetworkAgentInfo [WIFI () - 111] to 60
02-13 19:36:22.166 1204-1397/? D/ConnectivityService: sending new Min Network Score(60): NetworkRequest [ id=1, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ], isSkipMobile=false

This issue i am getting…