-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android build crushes with NoAudioHardwareException on device #6452
Comments
Hmm, this does not occur on any of my Android devices. Possible cause might be that android package is extracting libopenal32.so to a different location on some phones. If anyone has a device that has this problem and wants to debug this, step 1 is checking if https://github.com/MonoGame/MonoGame/blob/develop/MonoGame.Framework/Audio/OpenAL.cs#L225 is IntPtr.Zero. |
@cra0zy, I did checkout for 017c1a7, added monogame Android project to my test project and change monogame reference to it. After that, I set a breakpoints: one at the line you requested and one at return. Just so I am clear how I get this, as I said new to it. At line 225 ret is 0x0, at line "return ret;" ret is still 0x0. |
Okey, that tells us dlopen is failing, next up is to read the error, Replace method https://github.com/MonoGame/MonoGame/blob/develop/MonoGame.Framework/Utilities/FuncLoader.Android.cs#L16 with: [DllImport("dl")]
public static extern IntPtr dlerror();
private static unsafe string GetString(IntPtr handle)
{
if (handle == IntPtr.Zero)
return "";
var ptr = (byte*)handle;
while (*ptr != 0)
ptr++;
var bytes = new byte[ptr - (byte*)handle];
Marshal.Copy(handle, bytes, 0, bytes.Length);
return Encoding.UTF8.GetString(bytes);
}
public static IntPtr LoadLibrary(string libname)
{
var ret = dlopen(libname, RTLD_LAZY);
var s = GetString(dlerror());
System.Diagnostics.Debug.WriteLine("Error: " + s);
return ret;
} And tell me whats the contents of the variable s. |
@cra0zy it's Error: dlopen failed: library "libopenal32.so" not found |
Hmm... try the following (replace your.package.id with your android game id):
and give me the output of this. |
@cra0zy Not sure if I did it right (but this is indeed from my Xiaomi device, not an emulator or anything and if I run the package with this name from device I got the same error, so everything should be right here), but I got this: |
So libopenal32.so does get extracted... well then, the problem is that dlopen fails to find the library for some reason 🤔 Try changing the path in: https://github.com/MonoGame/MonoGame/blob/develop/MonoGame.Framework/Audio/OpenAL.cs#L225 to stuff like "lib/libopenal32.so" etc. and tell me if you find a path that succeeds. Extra notes:
|
@cra0zy I made use of pwd and was able to make it work by writing full path even with my package name like this: |
Perfect :) Thank you very much for your help. I'll have a PR that is fixing this issue ready tomorrow morning. |
I can confirm it's now working great on both my Xiaomi devices! Thanks for being patient with me and thank you for all your Monogame work! |
Fixed in #6454! |
We getting reports of this crash still and have the above fix in. I'm not sure which devices yet. Kindles and some others. |
So, gonna close this as the original issue has been fixed, there is another issue present with newer versions of Xamarin Android (which I noticed some time ago, but thought it was a Linux only error). See #6831 for our bug on this |
Running empty Monogame Android VS template on real device throw NoAudioHardwareException immediately. Full error is:
The issue occurs with both nuget version (3.7.0.1708 and 3.7.0.1681-develop).
I cloned and checkout some older commits (I'm new at this stuff, sorry if I'm using wrong terminology). Everything before 017c1a7 works, everything after doesn't, including this commit fc0afb3
In over words if there is FuncLoader in Utilities, problem will occur.
Issue seems to be related to #6382 and based on the last comment and my experience it may be related to Xiaomi phones, maybe even exclusive to it.
I was able to test it on Xiaomi Note 4, Xiaomi Redmi 5 exception occuir on both. But it doesn't with Android emulator (Oreo 8.1). Sadly I don't have any other Android phone, so I can't test anything else.
What version of MonoGame does the bug occur on:
What operating system are you using:
What MonoGame platform are you using:
The text was updated successfully, but these errors were encountered: