Issues when port cocos2d-x iphone game to android

Hi all,
I am trying to port a cocos2d-x iphone game to android. I can generate the apk file for android. But the sounds in the game seems load very slow in the android emulator. What’s worse, the android game crash with the log (E/AudioCache( 33): Heap size overflow! req size: 1052672, max size: 1048576). And the the VM shut down.

Can any body give me some ideas?

Thank you!

I think you should test it on real phone.
Is the sound too big?

Thank you Minggo. I have replace the mp3 file with smaller audio file, and there is no (E/AudioCache( 33): Heap size overflow! req size: 1052672, max size: 1048576). But the app still crash.
And when the app crash, there is an dialog popup and says, “get data from file faild.” Then the app crash, but there is no log related to this crash.

Can anybody help?

Thank you!

Hi, Yang, Can you paste a screenshot of the popup msgbox? I guess what you meet is CCFileUtils::getDataFormFile failure. It’s normally caused by the invalid path of resource. Please check if the new audio file is packed into apk ball.

In android, the audio file should be put in Resource/.

Thank you Minggo and Walzer!
I found the issue. It’s something related to getting values from plist file. And I describ the details in this thread(http://www.cocos2d-x.org/boards/10/topics/2489).
could you help?

Thank you.

I encounter the same problem when port cocos2d-x iphone game to android now , and my log is as follow:

05-02 21:52:13.823: W/SoundPool(2749): sample 1 not READY 05-02 21:52:13.995: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:13.995: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.003: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.003: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.003: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.003: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.003: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.003: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.011: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.011: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.011: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.011: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.011: E/AudioCache(1928): Heap size overflow! req size: 1052672, max size: 1048576 05-02 21:52:14.011: E/AudioCache(1928): Heap size overflow! req size: 1052176, max size: 1048576

This is tested in my real phone.

My background music is 62s long.

I use SDK .10 and NDK r6b.

All my OGG audio files is 1.62MB, as I know, the OGG is the smallest format for audio, so I don’t know how to minish my audio file.

Can any body give me some ideas?

Thank you!

Me too porting the iOS cocos2d game: I have one sound constantly played as background and want to play another not small mp3 (1 mb, 60 s) at the same time. First it says “sample not ready” and then “Heap Size overflow”. I’ve found that it is not recommended to play big files as effects on android.

Is there may be any solution now? Did someone tried for example extend SimpleAudiEngine to allow play another sample using MediaPlayer?

Hello again. As a possible solution I tried to extend Cocos2dxMusic.java with the second set of methods -like preloadBackgroundMusic() etc.

I also extended the JNI interface of a SimpleSoundEngine. But on first invokation I get “not static method with name=”preloadBackgroundMusic2" in class org/cocos2dx/lib/Cocos2dxHelper".

What I am still missing?