LibretroDroid
LibretroDroid copied to clipboard
dlopen failed: library "mgba_libretro_android.so" not found
Hi, i just load up the project in Android Studio. Make sure to change the hardcoded paths to existing ones in SampleActivity..
When
retroView = GLRetroView(this, "mgba_libretro_android.so", pathtogame, "", "", LibretroDroid.SHADER_LCD)
gets called tho, the above error gets thrown.
Does happen with any other core too. It happens on:
void LibretroDroid::Core::open(const std::string& soCorePath) {
libHandle = dlopen(soCorePath.c_str(), RTLD_LOCAL);
To get the detailed (in headline) error log i logged dlerror() like
void LibretroDroid::Core::open(const std::string& soCorePath) {
libHandle = dlopen(soCorePath.c_str(), RTLD_LOCAL);
if (!libHandle) {
LOGE("Cannot dlopen library, closing");
LOGE("%s",dlerror());
Any idea? :)
Hi,
Yeah, the current sample application is just terrible. You need to provide the mgba core in the respective jniLib forlder for your architecture.
Just check how this is done for arm64. You can get the proper so file from buildbot.
Hi, thats what i already did, and why its so confusing to me :( https://s12.directupload.net/images/200822/fpkpjxsi.png
EDIT: Seems to be related to the android version, testing with android 7, it doesnt work Can be reproduced by creating a x86 or x86_64 device on android nougat using the strandard avd manager :) It does work on android 8, just 7 seems to be not working
Mmmmh. This seems very strange. Could you please try renaming the library to "libmgba_libretro_android.so"? Maybe the library doesn't get extracted to the lib directory because the filename doesn't start with "lib".
Librarys got extracted correctly. It seems tho that android 7 and previous dont like to only get the librarys name.
So to work, when passing the .so on creation of the GLRetroView, you can just append the path to the apps native lib dir, in kotlin thats then like:
retroView = GLRetroView(this, getApplicationInfo().nativeLibraryDir+"/mgba_libretro_android.so", "/storage/emulated/0/test.gba", filesDir.absolutePath, cacheDir.absolutePath, LibretroDroid.SHADER_CRT)
Works fawlessly now, thanks! :)
Thanks for the solution, I'll be using this workaround until the LibretroDroid library is updated (unless it's a wontfix
).
BIG heads up:
With release APKs, the libretro library MUST BEGIN WITH lib
. For example, "mgba_libretro_android.so" will NOT be extracted upon launch in a release APK. However, "libmgba_libretro_android.so" WILL.
@tytydraco Yeah, there are lots of traps in there. The library has to start with "lib" to be copied into the native library directory.
The path is passed automatically to dlopen so you can also specify the library name ("foo" is actually resolved into "libfoo.so").
But here's the kicker: the default Android behaviour changed with gradle plugin 3.6.0. Libraries are no longer installed in the native library directory, but you need to specify a flag in gradle.properties AND put extractNativeLibs=true
in Manifest.
I'm planning to write a blog post in the future since I've lost many days on the topic. :smile: