1

I'm using this answer: https://stackoverflow.com/a/18739812/2904688 to split my android app into an APK and ZIP and it works like a charm.

Although the app launches properly all sounds are not playing. Cocos2dxMusic.java & Cocos2dxSound.java seem to not be able to read the sound files in the zip. All assets (images, animations, etc) load correctly but the sounds (music & SFX) seem to not load.

The relative to the assets.zip path is correct as given by the logs. Any clues? I am using cocos2d-x 2.2.0

Here's the error codes thrown:

03-20 08:29:08.275: E/Cocos2dxMusic(31653): error: Attempt to invoke virtual method 'android.content.res.AssetFileDescriptor.com.android.vending.expansion.zipfile.ZipResourceFile.getAssetFileDescriptor(java.lang.String)' on a null object reference

03-20 08:29:08.275: E/Cocos2dxMusic(31653): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetFileDescriptor com.android.vending.expansion.zipfile.ZipResourceFile.getAssetFileDescriptor(java.lang.String)' on a null object reference

03-20 08:29:08.275: E/Cocos2dxMusic(31653):     at org.cocos2dx.lib.Cocos2dxMusic.createMediaplayer(Cocos2dxMusic.java:249)

03-20 08:29:08.275: E/Cocos2dxMusic(31653):     at org.cocos2dx.lib.Cocos2dxMusic.playBackgroundMusic(Cocos2dxMusic.java:112)

03-20 08:29:08.275: E/Cocos2dxMusic(31653):     at org.cocos2dx.lib.Cocos2dxHelper.playBackgroundMusic(Cocos2dxHelper.java:143)

03-20 08:29:08.275: E/Cocos2dxMusic(31653):     at org.cocos2dx.lib.Cocos2dxRenderer.nativeRender(Native Method)

03-20 08:29:08.275: E/Cocos2dxMusic(31653):     at org.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(Cocos2dxRenderer.java:94)

03-20 08:29:08.275: E/Cocos2dxMusic(31653):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)

03-20 08:29:08.275: E/Cocos2dxMusic(31653):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

03-20 08:29:08.275: E/Cocos2dxMusic(31653): playBackgroundMusic: background media player is null
Community
  • 1
  • 1
  • after more research, I noticed that `zip_resource_file = APKExpansionSupport.getAPKExpansionZipFile(pContext, 2, 0);` returns NULL. where "2" is my android versioncode – robojiannis Mar 20 '15 at 11:44
  • replacing the above mentioned line with `zip_resource_file = new ZipResourceFile( Environment.getExternalStorageDirectory() + "/Android/obb/" + pContext.getPackageName() + "/main.1." + pContext.getPackageName() + ".zip");` works, but I'm not sure if this is the cleanest solution? – robojiannis Mar 20 '15 at 12:41

0 Answers0