I’m developing a game called GnollHack (GitHub - hyvanmielenpelit/GnollHack: Rogue-like game based on NetHack) which uses FMOD version 2.02.26 as a sound middleware. It works well on Android physical devices and Android emulator in Visual Studio. However, we just tested the new Google Play Games on PC Developer Emulator (Download the Google Play Games on PC Developer Emulator | Android game development | Android Developers) through which one can play Android games on PC, and the sounds do not work there. FMOD does initialize successfully, though (no error).
It probably is some sort of an incompatibility between FMOD and Google Play Games on PC Developer Emulator. I just wanted to ask if anybody knows what the problem in fact is, and if there is a workaround for it?
Hi,
Unfortunately, I’ve haven’t been able to reproduce the behaviour you’re describing - I’m able to run builds of the FMOD examples included with the FMOD Engine Android installer and have sound output correctly from the Google Play Developer Emulator.
Could I get you to use Debug_Initialize
before system creation/initialization to set flags
to FMOD_DEBUG_LEVEL_LOG
, create and run a debug build of the app on the emulator, and post a log captured by logcat
where the issue occurs?
Here’s the log from the emulator using logcat.
log.txt (2.1 MB)
I’m using the following code to initialize FMOD in C# on Android before system creation:
private static void LoadNativeLibrary(string libName)
{
Java.Lang.JavaSystem.LoadLibrary(libName);
}
public static void AndroidInit(Context p0)
{
LoadNativeLibrary("fmod");
LoadNativeLibrary("fmodstudio");
Org.Fmod.FMOD.Init(p0);
}
Sorry, I forgot to mention: you’ll need to use the logging version of the FMOD libs in order to have Debug_Initialize
log correctly. Please swap to those libs, and capture and post the log again.
You can recognize the logging libs by the ‘L’ suffix in the library name, for example fmodL.dll or libfmodL.so. After ensuring the logging libs are correctly included in your solution, you’ll want to call LoadNativeLibrary("fmodL");
and ``LoadNativeLibrary(“fmodstudioL”);` instead of the existing calls.
I believe that I already used those files earlier, as Debug_Initialize crashes in the emulator without the libraries ending in L. But I will double-check.
I double-checked that the fmodL.so library was being used. Here’s the new (very similar) log from today. There only two FMOD lines there:
01-31 16:40:52.673 2732 2732 I fmod : FMOD_OS_Init : Detected CPU family: 5, features: 0xFF, cores: 4.
01-31 16:40:52.673 2732 2732 E fmod : FMOD_JNI_GetEnv : JNI_OnLoad has not run, should have occurred during System.LoadLibrary, or during FMOD_Android_JNI_Init if using NativeActivity.
It seems that JNI_OnLoad does not run in the emulator, and then nothing else starts or gets logged.
log2.txt (1.7 MB)
In that case, it’s likely that your program is missing a call to org.fmod.FMOD.init()
on the Java side of things. I’m unsure on the specifics of MAUI, but if you don’t have the direct ability to call Java, you’ll have to use some kind of wrapper similar to what we do in the FMOD Unity integration:
// AndroidJavaClass is a Unity-specific class, dotnet/MAUI may have an equivalent
using (var fmodJava = new AndroidJavaClass("org.fmod.FMOD"))
{
if (fmodJava != null)
{
fmodJava.CallStatic("init", activity);
}
}
or directly call FMOD_Android_JNI_Init and the corresponding FMOD_Android_JNI_Close from a native activity.
I suppose is not a coincidence we are looking now to the same problem as we also need to port our game to the PC version in google store.
We have the same problem: no audio in the emualtor.
Thanks for letting me know. I’ve passed this issue along to the development team to take a closer look.
Just to confirm though, if you run an Android FMOD Engine example on the emulator, do you run into the same issue?
Just to expand on what I mentioned earlier in the thread: calling LoadLibrary
from C# isn’t enough, because the context of the class loader is wrong - you’ll need to call LoadLibrary
from Java. If this isn’t possible, then you’ll need to do as I’ve mentioned earlier in the thread, and call FMOD_Android_JNA_Init
and FMOD_Android_JNI_Close
from C# instead.
Hi Leah, I’m not sure what has happened, but I just compiled the game again with the newest version of Visual Studio, and the sounds seem to work now. This is in fact the Xamarin version of the game; .NET MAUI has some other problems with the emulator, for which reason I cannot test it yet. It may also be that the emulator got automatically updated, but not sure about that.
No problem, happy to hear that it’s working for you now. Feel free to let me know if you run into any more issues.