I am trying to use SDL2 with .NET MAUI.
I have tried to build the native libraries using the androidbuildlibs.sh at the buildscriprs directory. it generated libSDL.so for different architectures. and then I added them to libs/ directory in the project and set there build action to AndroidNativeLibrary. when I try to Initialize SDL using:
[DllImport("libSDL2.so", CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_Init(uint flags);
the SDL_Init method returns -1.
I thought I should Initialize it somewhere in the MainActivity. so, I built the java library that contains SDLActivity to .jar file and I made a binding project to it. then I tried to make the MainActivity inherit from SDLActivity instead of MauiAppCompatActivity. and I overrided the LoadLibraries method like so:
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : SDLActivity
{
public override void LoadLibraries()
{
base.LoadLibraries();
SDL2Helper.InitSDL();
}
}
Now I get an error indicating that the libmain.so not found.
You need to sign in to view this answers