Does SDL work on Android with extractNativeLibs=false?

Has anyone had luck getting SDL to work with extractNativeLibs set to false in the AndroidManifest.xml? I ask because it’s not working for me and digging into it, I’m not sure how it would work anyway.

As I understand it, when extractNativeLibs is set to false, the .so files are just stored uncompressed in the APK, not extracted. So the application is supposed to just load these directly from the APK. But in SDL_android.c, it is specifically trying to load the library with a file path. So instead of the library loading, I am getting an error in logcat that says “Couldn’t load library /data/app/blah/blah/blah/lib/x86/libmain.so”. But when extractNativeLibs is set to true, it works fine - obviously because the files are just sitting there waiting to be loaded.

This problem came up because I submitted an Android App Bundle to the Google Play Store (as it recommended), and it seems that it’s giving out APKs with extractNativeLibs set to false for all devices on Android 9 (I don’t know if this is true for everything on Android 9, but it tracks in this case). So for everyone on Android 9, the game just shuts down immediately when they start it. I’d prefer it didn’t.

I’m looking to see if there is a way to force extractNativeLibs to true for all APKs generated from my AAB, but I still wonder if extractNativeLibs=false has worked for anyone else and if there’s something else I should be doing.

Read this thread Android bundle and nativeLibraryDir returned by getMainSharedObject()

short answer: there was a patch https://bugzilla.libsdl.org/show_bug.cgi?id=4739

2 Likes

Thank you so much, I’ve been stressing over this issue for the past 3 weeks (I figured it was something I was doing wrong in the manifest or something), only recently suspecting SDL, and this was exactly what I needed.

I applied the patch, tested it, uploaded it, and users are telling me it’s working for them now.

Thanks again!

1 Like