Android application fails to start (error info included)

Thanks Nezz! I’ll make sure to test it again with a Nexus device later today. Meanwhile, what do you think is going wrong with these error messages in the application output?

[Mono] DllImport attempting to load: ‘libEGL.dll’.
[Mono] DllImport error loading library ‘./libEGL.dll’: ‘dlopen failed: library “/data/app-lib/TheGame/./libEGL.dll” not found’.
[Mono] DllImport error loading library ‘./libEGL.dll.so’: ‘dlopen failed: library “/data/app-lib/TheGame/libaot-libEGL.dll.so” not found’.
[Mono] DllImport error loading library ‘libEGL.dll’: ‘dlopen failed: library “/data/app-lib/TheGame/libEGL.dll” not found’.
[Mono] DllImport error loading library ‘libEGL.dll.so’: ‘dlopen failed: library “/data/app-lib/TheGame/libaot-libEGL.dll.so” not found’.
[Mono] DllImport error loading library ‘libEGL.dll’: ‘dlopen failed: library “/data/app-lib/TheGame/libEGL.dll” not found’.
[Mono] DllImport error loading library ‘./libEGL’: ‘dlopen failed: library “/data/app-lib/TheGame/./libEGL” not found’.

I think that is the pertinent bit in the logs. As Nezz implies, I think you can edit the emulator image settings and enable GPU acceleration.

I’ve also read good things about this emulator: https://www.genymotion.com/

Google’s Android emulator by default only supports OpenGL ES 1.1 in software. To use OpenGL ES 2.0 (required by MonoGame) you need to enable GPU acceleration.

The Visual Studio Android emulator (same as the Xamarin Android emulator) provides hardware acceleration and launches a lot faster than Google’s emulator.

Thanks @Nezz, @Aranda and @KonajuGames! I tested the game with a Nexus 7 device and it seems that problem is now gone (or bypassed?). However there is a new issue that prevents the game from running: Xamarin Studio doesn’t support the “Content” build action on Android, resulting in the error message below:
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Fonts/titleFont asset as a non-content file! —> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. —> Java.IO.FileNotFoundException: Exception of type ‘Java.IO.FileNotFoundException’ was thrown.

And it seems Xamarin hasn’t figure out a way to solve this:
http://developer.xamarin.com/guides/android/under_the_hood/build_process/
“Content
The normal Content Build action is not supported (as we haven’t figured out how to support it without a possibly costly first-run step).
Starting in Xamarin.Android 5.1, attempting to use thw @(Content) Build action will result in a XA0101 warning.”

I wonder if there is a way to fix this problem?

For Android, you should use the BuildAction of AndroidAsset (and Do not copy) instead of Content. Also your whole Content folder should be inside an Assets folder at the root of the Android project.

Thanks so much for your help @Aranda! I followed your instructions but the same error is still there. The content files were built using the old MG content pipeline project with the Android configuration. I’ve been using that pipeline project to build content for the iOS version of my game, so the content itself shouldn’t be the cause of this problem. I really don’t know what to do now. Never expected that porting an existing project to Android could be this messy… :frowning:

Haha, yeah almost everything to do with Android is messy :stuck_out_tongue:

I also had this problem and found that text searching through the .csproj file for “<Content” found the offending item. In my case it wasn’t actually a content file - I think it was the AndroidManifest.xml which can have a BuildAction of None

text searching for what? :smile:

Oh damn, “Content”, with the opening angle brace, but not the closing one. Forums must have interpreted it as malformed HTML :slight_smile:

[EDIT] But failing that, check every single file in the whole project to make sure Build Action is not set to Content.

Here is what I have:
< ItemGroup>
< AndroidAsset Include="Assets\Content\ ** \ . " >
< /AndroidAsset>
< /ItemGroup>
And that is same method I used for WP8 and iOS contents. :smile:

Ok, that’s the game’s content files, but the error you are getting implies there is some other file with:
< Content Include="…">

Well it was “Content” but I manually changed it to “AndroidAssets”… If I set it back to “Content” the build action will become “Content”…

Also I checked the .apk file using WinRar. The Assets/Content folder, together will all the .xnb files, is in there…

I meant check inside the .csproj file for any other occurances of <Content Include="...">, ie files that are not assets. That was the problem for me anyway.

I checked all over the .csproj file and there is no other occurrence of < Content Include = “…”>…

I wonder if the “Content” build action has ever been available in the previous versions of Xamarin? The build action for the contents of the WP8 version and iOS version of my game is “Content”, and it seems the “AndroidAssets” build action is not working well with MG content files… :frowning:

I recently upgraded my Xamarin.Android version and this error just started appearing, so I’m guessing that Content build actions were just ignored before. When I removed the one on my AndroidManifest.xml, the error went away. That’s why I assumed you must have a file in one of your projects that is still set to Content. If not, then I’m not sure, sorry.

I just looked more closely at your error log - perhaps the Content build action error is a red herring because this looks like the actual problem. I’m pretty sure Android file system is case-sensitive, so make double sure you have Assets/Content/Fonts/titleFont.xnb (with that case) inside the APK file.

Thanks so much @Aranda! I think I kind of figured out why: I set the root directory of Game.ContentManager to “Assets/Content”, while it was originally set by the MG template as:
Content.RootDirectory = “Content”;

I changed it back and the loading errors of those xnb files are gone. But it seems there are still other data loading issues caused by this inconsistent file structure… Guess I’ll have to fix them later…

Quick question: do I need to change all the ContentManager initialization lines to the Android way? I.e. something like this?
if (content == null) {
#if !ANDROID
content = new ContentManager (Game.Services, “Content”);
#else
content = new ContentManager (Game.Services, “Assets/Content”);
#endif
}

Thanks very much again for your help! :smile:

ContentManager already accounts for that. Strange that it didn’t work for you without adding that to the root directory.

Oh I found out that it wasn’t the ContentManager but the XmlReader. I have somehow solved it (plz see this thread: Error during loading an XML file using XmlReader on Android ). Thanks Nezz! :slight_smile: