Hello ![:slight_smile: :slight_smile:](https://community.monogame.net/images/emoji/twitter/slight_smile.png?v=9)
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.
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:
<AndroidApplication>True</AndroidApplication>
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).