[BUG] JME3.3.2-stable, Android, ogg, not playable

I am having a problem with playing ogg at android, i am just can’t get what it wrong. At the pc it works nice but i can’t run it at android (i have android 9 at the phone xiaomi 5 note pro if it is matters)

my code leads to the error:

 java.lang.IllegalArgumentException: capacity < 0: -524
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:254)
	at com.jme3.util.AndroidBufferAllocator.allocate(AndroidBufferAllocator.java:111)
	at com.jme3.util.BufferUtils.createByteBuffer(BufferUtils.java:989)
 obtainBuffer(590) returned 90 = 90 + 0 err 0
	at com.jme3.audio.plugins.NativeVorbisLoader.loadBuffer(NativeVorbisLoader.java:72)
 obtainBuffer(500) returned 0 = 0 + 0 err -11
	at com.jme3.audio.plugins.NativeVorbisLoader.load(NativeVorbisLoader.java:130)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:260)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:374)
	at com.jme3.asset.DesktopAssetManager.loadAudio(DesktopAssetManager.java:405)
	at com.bukazoid.games.Game1.lambda$null$7(Game1.java:434)
	at com.bukazoid.games.Game1.accessor$Game1$lambda7(Unknown Source:0)
	at com.bukazoid.games.Game1$$Lambda$7.run(Unknown Source:6)
	at com.bukazoid.games.basics.Safe.lambda$wrap$0(Safe.java:27)
	at com.bukazoid.games.basics.Safe.accessor$Safe$lambda0(Unknown Source:0)
	at com.bukazoid.games.basics.Safe$$Lambda$0.run(Unknown Source:4)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:764)

my code is

_executor.execute(Safe.wrap(() -> {
                    log.info("create audio node");
                    AudioKey aKey = new AudioKey(musicFile);
                    AudioData aData = assetManager.loadAudio(aKey); // line 434
                    log.info("aData: {}", aData);

                    musicNode = new AudioNode(aData, aKey);

                    //musicNode = new AudioNode(assetManager, musicFile, DataType.Buffer);
                    log.info("audio node created: {}", musicNode);
                    musicNode.setName("background music");
                    enqueue(Safe.wrap(() -> {
                        log.info("play music");

but it is done at
AudioData aData = assetManager.loadAudio(aKey);

it looks like it it asking for negative buffer size: -524

jme 3.3.2-stable is used, same for 3.2.2-stable(i did migrate trying to solve the problem)
file size is: 1,084,807 bytes, i did get it for private usage, maybe i wil lbuy it in future.

So i can’t play mp3 - ok, i can’t play audio form non assets directory - ok, i may live with this, but i also can’t play file from android’s assets directory and it is fail for me.

Can you give me piece of advice how to manage this error? i can’ dig code a bit, but i need directions, also, it looks like it ends at native android’s code

1 Like

What JME version are you using?

1 Like

JME 3.3.2-stable is used,
i did update post coz it is important information

1 Like

also i am using eclipse and project is quite old (still maven is used), but apk structure looks ok.

Have you tested the audio file with something like VLC player to ensure it is valid?

Does it give the same error with JME 3.2?

Suspect this might be related


yes, file it fine, i did download mp3 and did use ffmpeg to convert it to ogg. Maybe it is too big (1,084,807 bytes). I will try file for jme3 source

Can you try with the ogg files from jme-testdata


It is working in version 3.3.0-alpha2!

I am not sure about 3.2.2, coz i was trying to load file from some application’s directory (download it from server before play, it makes apk smaller and testing easy). So maybe for 3.2.2 it was ok but i was unable to play file coz it was not at assets directory. I will check the thread for resolution and may be i will be able to help with testing some stuffs.

1 Like

I have almost 2 a.m. last test and i am done for todays, thanks!

3.2.4-stable is ok too, thanks


Yeah, actually sound on android is broken since JME 3.3.0-alpha5 after we updated the build script to build android natives on the CI.


You can yet keep using JME 3.3.2-stable for other jars and just use 3.3.0-alpha-2 for jme3-android-native.jar and you should be fine.


btw, @bukazoid thanks for providing the error stack trace, now it is a bit more clear with what goes wrong on native side. :slightly_smiling_face: