Embedding OpenAL compilation issue

Hello :slight_smile:

We are setuping a new project using the latest MonoGame sources using Xamarin Studio 5 and we stumbled upon a strange issue with the Android target.

When compiling MonoGame, there is the following error regarding actions on the libopenal32.so files: “EmbeddedNativeLibrary is invalid in Android Application project. Please use AndroidNativeLibrary”.

Well, I know that EmbeddedNativeLibrary is correct (and that the suggested change will result in runtime errors), but the strange thing is that Xamarin Studio consider the project to be an “Android Application”. I double checked the csproj file created by Protobuild and the output is correctly set to Library.

Cleaning the solution and restarting Xamarin Studio does not help.

Any insights are welcome.

Looks like a Xamarin bug introduced in one of the latest Xamarin.Android which makes MSBuild to think a Library project is an Application project when it comes to the task CheckProjectItems.

I am going to check this with Xamarin and report back here so this issue is documented.

Weird, I haven’t ran in to this and I believe I’m compiling with the latest versions of everything.

Thank you for commenting, that makes me think it is a problem with my installation. I’ve already tried to go back to Xamarin Studio 4 and Xamarin Android 4.12.3 and did not change anything. I think that the successive automatic updates of Xamarin over a year messed a little bit with my dev environment.

I will try a clean install when I can afford the time and keep this post updated.

I have the exact same issue (and was apparently too dense to look in this forum before posting a new thread). This was the closest thing I could find: http://mono-for-android.1047100.n5.nabble.com/Getting-OpenAl-working-td5712296.html. I’ve tried, but the solution posted in that thread doesn’t work for me at all. Maybe you’ll have better luck.

It does not seem to be the same problem. The link you shared is about linking OpenAL with a Xamarin.Android application without MonoGame.
If you have the same problem and try to use the AndroidNativeLibrary build action on the OpenAL libs in the MonoGame project, it will successfully build but you will have runtime errors when you call sound functions because the .so files will not be correctly embedded in the MonoGame.Framework.dll.

I still don’t have a clue about this issue besides trying a reinstall and I hope you will be able to sort this out too.
Thanks for digging into this.

EDIT: I just saw your post, it’s indeed the same problem but the mentionned link won’t help. :confused: I am going to check this with Xamarin as it’s not an isolated case.

I haven’t checked audio yet but I assume I have the same problem as my Android projects are starting to give me the following in the App Output…

DllImport attempting to load: ‘openal32.dll’.
[Mono] DllImport error loading library ‘./libopenal32.dll’: ‘dlopen failed: library “/data/data/GameTemplate.GameTemplate/lib/./libopenal32.dll” not found’.
[Mono] DllImport error loading library ‘./libopenal32.dll.so’: ‘dlopen failed: library “/data/data/GameTemplate.GameTemplate/lib/./libopenal32.dll.so” not found’.
[Mono] DllImport error loading library ‘libopenal32.dll’: ‘dlopen failed: library “/data/data/GameTemplate.GameTemplate/lib/libopenal32.dll” not found’.
[Mono] DllImport error loading library ‘libopenal32.dll.so’: ‘dlopen failed: library “/data/data/GameTemplate.GameTemplate/lib/libopenal32.dll.so” not found’.
[Mono] DllImport error loading library ‘openal32.dll’: ‘dlopen failed: library “/data/data/GameTemplate.GameTemplate/lib/openal32.dll” not found’.
[Mono] DllImport error loading library ‘./libopenal32’: ‘dlopen failed: library “/data/data/GameTemplate.GameTemplate/lib/./libopenal32” not found’.

This is Mono attempting to load OpenAL lib, it checks every possible file names and extensions before finding the good libopenal32.so files.
If everything is ok, just after these errors you should see that Mono found the good one. Moreover, if OpenAL was properly embedded, you will see a few initialization debug lines with the [OAL] tag. As long as you have this, you can ignore the import errors.

However, if there’s no [OAL] initialization, it probably means that you compiled MonoGame using AndroidNativeLibrary build action on the .so files (instead of the correct EmbeddedNativeLibrary), which will not embed the lib in MonoGame.Framework.dll.

Thanks for this, maybe all is OK then as I do have [OAL] init lines later…

[OAL] Does not support low latency audio playback.
[OAL] Using sample rate 44100Hz and 2 buffers of 512 frames.

Hopefully I’ll get onto audio properly later this week once my other problems are sorted!

I don’t believe it’s a problem with Xamarin, as building the MonoGame.Framework.Android solution in Visual Studio gives the exact same error messages.

Seems pretty normal since the build chain is the same and use the same tools.
I have debugged the MSBuild output and the task that is failing is CheckProjectItems, which belongs to a Xamarin.Android build task inside the Xamarin.Android.Build.Tasks.dll assembly. I doubt it is a problem with the project configuration, so my best bet is that something is wrong with the MSBuild Xamarin tasks.

I found the culprit… It was there, in front of me, the whole time.

It seems that Xamarin Studio adds the following line to the csproj:


This overrides the output type for Xamarin MSBuild tasks. Setting it to false or simply removing it makes everything compile and work just fine.

I have checked the vanilla csproj generated by Protobuild and this line is not present. This line appears in the csproj file if one tries to edit the project properties or import the csproj into another project. I think that Xamarin.Android consider that it is an “Application” because of the presence of a manifest.xml file and will add this line if it has to update the csproj file.

So, it’s definetly not a MonoGame or Protobuild issue, but a Xamarin.Android one which wrongly adds metadata to the csproj if the project is imported or modified. I will report back to Xamarin and hopefully this will be patched.

Have you gotten any sort of response from the folks over at Xamarin?

After further investigation, I found that it is a problem with Protobuild which wrongly adds a manifest file to library projects.

It is not a Xamarin issue and they won’t patch this behavior since manifest files are not meant to be included in library projects.

I have submitted a PR to Protobuild and once it is merged, Protobuild.exe has to be updated on the MonoGame repo (I will check this and make a PR to MonoGame if my Protobuild PR is validated).