AudioEngine V4.0 vs V3.17.2

AudioEngine V4.0 vs V3.17.2

V 3.17.2

void AudioEngine::remove(int audioID)

V 4.0

void AudioEngine::remove(int audioID)

The same for uncache()

Is it a bug fix? I use 3.17.2 and my wav sound doesn’t play in apk release mode if app is downloaded from store, but play if I launch the debug apk directly on the device.
So I’m trying to found where is the bug.
On IOS no problem, all is fine…

Any help will be appreciated.


Is it possible that it is my problem?

I preload ± 80 sounds.
IOS all is ok (debug + release).
In debug mode all is woking
APK release impossible to play a sound.

How large are those 80 sound files? When they’re converted in memory, how much memory do they take up? Have you tried uploading the release APK manually to the device, and checked logcat to see if there are any warnings or errors emitted by the app?

Create a custom release version with logging enabled, upload it to your device, and check the output to see what might be happening. It’s a lot quicker than trying to guess what the problem may be.

File size matters. Check it. I believe there’s 256 KB (or something close to this number) limit. After reaching it, different audio engine is used (web audio engine). It’s only on Android. An easy fix is to increase that limit and recompile cocos2d-x.

R101-> All the file are 38.5 mb
I will try now uploading the APK directly.

piotros, how do I increase the limit?

I rooted my samsung, it is more easy than to publish always. I build a release APK will all inside (±250 mb), and I install the apk directly all is working.

If I split my APK with the software + sounds (±50mb) and the atlas in a OBB/ZIP file, sounds don’t play, the game start, all look good but no sound.

the problem is here:

AudioPlayerProvider::AudioFileInfo AudioPlayerProvider::getFileInfo(
        const std::string &audioFilePath)
     assetFd = _fdGetterCallback(relativePath, &start, &length);

        if (assetFd <= 0)
            ALOGE("Failed to open file descriptor for '%s'", audioFilePath.c_str());
            return info;

all the path are ok.
Any idea?

It may be related to this:

Hi R101,
the problem is clear now for me, if you have an OBB file, for unknow reason the sounds in the APK are not played.

I made this test, all in my APK (sound+atlas sheet sprite), the sounds are played.
If I launch exactly the same APK and I previously added a OBB file in the folder Android/data/obb/com.mycompany.myApp/
so the sounds are corrupted

Inside this obb there is only one ATLAS folder (the same than in the APK) not the sounds, the game start but no sounds are played, it fails always in getFileInfo
assetFd = _fdGetterCallback(relativePath, &start, &length); return 0
It seems that accessing obb file corrupt mechanism to play sounds.
I made a small project and had the same problem it is probably a bug or I’m missing something.

I solved like (I know this is not a solution but work for me, I know it is not good to modify cocosfiles)
Since I have only my Atlas in OBB file, when I launch the game I do:
// before to read Atlas in OBB

in ccFilesUtils-android.h
+    static void SetObb();
+    static void DeleteObb();
in ccFilesUtils-android.cpp
bool FileUtilsAndroid::init()
   _defaultResRootPath = ASSETS_FOLDER_NAME;
    return FileUtils::init();
void FileUtilsAndroid::SetObb()
        std::string assetsPath(getApkPath());
        if (assetsPath.find("/obb/") != std::string::npos)
            obbfile = new ZipFile(assetsPath);
void FileUtilsAndroid::DeleteObb()
    if (obbfile)
        delete obbfile;
        obbfile = nullptr;

@fabrice You should use the formatting options available to you in the editor on this forum to format the code you’re posting.