Home Features Docs Blog Support GitHub

[TEMP FIX] Libgdx - MOE - Cannot locate sound files error

I cannot load and play sound files when I tried to run on simulator. Other assets like textures don’t seem to have this problem. I’m using Gdx v1.9.6 and moe Intellij plugin v1.3.0 with 1.3.2 sdk.

I actually wanted to port an existing Libgdx project to iOS. First I created a base Libgdx project with ios-moe. Then I copied the ios-moe directory to the old project and changed the appropriate build gradles and other project files.

When I run the app in the simulator from IntelliJ, I’m getting this in the console and it crashes:

/Users/igloo/Documents/Libgdx/Projects/SampleProjectSansMoe/gradlew moeLaunch -Pmoe.launcher.options=no-build,no-install-on-target,config:Debug -Pmoe.launcher.simulators=84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7
Configuration on demand is an incubating feature.
Using already downloaded SDK: /Users/igloo/.moe/moe-sdk-1.3.2
:ios-moe:moeLaunchart I 3739 199823 /Volumes/SSD/Android/moe-final/aosp/art/runtime/parsed_options.cc:449] setting boot class path to /Users/igloo/Library/Developer/CoreSimulator/Devices/84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7/data/Containers/Bundle/Application/9BC97851-08A3-4FF3-AAEB-DD6FBBB2D285/SampleProjectSansMoe.app/application.jar:/Users/igloo/Library/Developer/CoreSimulator/Devices/84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7/data/Containers/Bundle/Application/9BC97851-08A3-4FF3-AAEB-DD6FBBB2D285/SampleProjectSansMoe.app

/Volumes/SSD/Android/moe-final/moe/natj/natj/src/main/native/natj/NatJ.cpp:353 DEBUG: Method ‘boolean java.lang.reflect.Method.isDefault()’ is not accessible.
IOSApplication 3 iOS version: 10.2
IOSApplication 3 scale: 2.0
IOSApplication 3 Status bar is visible (height = 20.0)
IOSApplication 3 Total computed bounds are w=640.0 h=1096.0
IOSGraphics 3 Display: ppi=163, density=2.0
IOSApplication 3 created
IOSApplication 3 resumed
IOSApplication 3 Status bar is not visible
IOSApplication 3 Total computed bounds are w=640.0 h=1136.0
IOSApplication 3 Status bar is not visible
IOSApplication 3 Total computed bounds are w=640.0 h=1136.0
Local dir path: /Users/igloo/Library/Developer/CoreSimulator/Devices/84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7/data/Containers/Data/Application/121D3AF0-7E32-4C6C-8946-EE4429C90AA8/Library/local/
2017-03-29 14:35:08.540 SampleProjectSansMoe[3739:199823] OAL Error: -[OALAudioTrack preloadUrl:seekTime:]: <OALAudioTrack: 0x7c150fa0: (null)>: Could not load URL file:///Users/igloo/Library/Developer/CoreSimulator/Devices/84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7/data/Containers/Bundle/Application/9BC97851-08A3-4FF3-AAEB-DD6FBBB2D285/SampleProjectSansMoe.app/assets/sampleaudio.ogg: The operation couldn’t be completed. (OSStatus error 2003334207.)
com.badlogic.gdx.utils.GdxRuntimeException: Error opening music file at /Users/igloo/Library/Developer/CoreSimulator/Devices/84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7/data/Containers/Bundle/Application/9BC97851-08A3-4FF3-AAEB-DD6FBBB2D285/SampleProjectSansMoe.app/assets/sampleaudio.ogg
at com.badlogic.gdx.backends.iosmoe.IOSAudio.newMusic(IOSAudio.java:67)
at com.bluejay.samplesansmoe.MyGdxGame.create(MyGdxGame.java:21)
at com.badlogic.gdx.backends.iosmoe.IOSGraphics.glkViewDrawInRect(IOSGraphics.java:228)
at com.badlogic.gdx.backends.iosmoe.IOSGLKView.drawRect(IOSGLKView.java:76)
at apple.uikit.c.UIKit.UIApplicationMain(Native Method)
at com.bluejay.samplesansmoe.IOSMoeLauncher.main(IOSMoeLauncher.java:22)
art I 3740 200109 /Volumes/SSD/Android/moe-final/aosp/art/runtime/parsed_options.cc:449] setting boot class path to /Users/igloo/Library/Developer/CoreSimulator/Devices/84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7/data/Containers/Bundle/Application/9BC97851-08A3-4FF3-AAEB-DD6FBBB2D285/SampleProjectSansMoe.app/application.jar:/Users/igloo/Library/Developer/CoreSimulator/Devices/84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7/data/Containers/Bundle/Application/9BC97851-08A3-4FF3-AAEB-DD6FBBB2D285/SampleProjectSansMoe.app
/Volumes/SSD/Android/moe-final/moe/natj/natj/src/main/native/natj/NatJ.cpp:353 DEBUG: Method ‘boolean java.lang.reflect.Method.isDefault()’ is not accessible.
IOSApplication 3 iOS version: 10.2
IOSApplication 3 scale: 2.0
IOSApplication 3 Status bar is visible (height = 20.0)
IOSApplication 3 Total computed bounds are w=640.0 h=1096.0
IOSGraphics 3 Display: ppi=163, density=2.0

BUILD SUCCESSFUL

Total time: 17.433 secs

If you look closely, I also printed the local storage path and it is:

Local dir path: /Users/igloo/Library/Developer/CoreSimulator/Devices/84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7/data/Containers/Data/Application/121D3AF0-7E32-4C6C-8946-EE4429C90AA8/Library/local/

But if you see the error statement:

com.badlogic.gdx.utils.GdxRuntimeException: Error opening music file at /Users/igloo/Library/Developer/CoreSimulator/Devices/84A18051-AD5D-44BC-ACA6-C0B3E9EFDFE7/data/Containers/Bundle/Application/9BC97851-08A3-4FF3-AAEB-DD6FBBB2D285/SampleProjectSansMoe.app/assets/sampleaudio.ogg

Both of them has different application IDs. I’m guessing it has something to do with this bug? How should I proceed from here? I tried mp3 and wav files as well, but the same error is thrown.

Edit: Here’s a link to a sample project: https://drive.google.com/open?id=0BxsAgLj5v1EESkhuQ1BCdUgyMVU

Thanks for the report.

We will take a look.

1 Like

Hi!

There is no built-in support for playing ogg files in iOS. Please see:

and

I added mp3 to sample project and fix it:
. Added assest to xcode project

Best Regards,
Roland

1 Like

@vighr Is mp3 working for you? I tested with mp3 and wav, but they won’t get detected either. Both Music and Sound class in Libgdx have this problem. Robovm had this issue too.

I think the error has something to do with not able to access the file rather than the file format. But thanks for the ogg tip in iOS. I’ll test your project asap.

Yes, mp3 worked fine

I got the same error with my audio files (.mp3 and .wav). In order to get them to play I had to manually add my asset folder to the “Supporting files” in xcode and not rely on “sourceSets.main.resources.srcDirs” in gradle which didn’t copy them.

Thank you both of you, that did the trick! Ogg is not supported in iOS and I copied the assets folder to the Supporting files in xcode project. I can hear the beautiful sounds again! ;D

All this time, I copied the assets folder to the root ios-moe folder in xcode. Never once thought of copying it to the current place. How dump!

Both Music and Sound classes are working.

This results in the assets being duplicated in the resulting .app, increasing your size of your bundle.

If you do this as a fix, remove the resources line in the build.gradle and delete your build files and recompile.

We can use this as a solution on the LibGDX side, also, but we should be able to use the resources path. As I understand it, resources are packed into the application.jar, whereas if you have a reference to the assets folder through xcode, it will just sit in the .app root directory as any custom asset directory would on iOS.

LibGDX file handles are using the main bundle base path + /assets/ as the path for internal assets, how do these get resolved to base path/application.jar/assets/? It seems that either way has no issue for assets that require a java File, but as music/audio paths are sent off to our open al library, these paths don’t make sense as it expects bundle base path + /assets/, which only exists if you add the reference in xcode so the assets actually get copied to that specific location (base bundle path + /assets/)

1 Like

That’s a great find! So that’s the reason why only music and sound classes show this problem.

Where should the patch work be done - in Libgdx or MOE?