android obb/zip music & sounds loading (cocos2dx)

心已入冬 提交于 2019-12-11 13:43:21

问题


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

来源:https://stackoverflow.com/questions/29164558/android-obb-zip-music-sounds-loading-cocos2dx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!