gilzoide / unity-sqlite-net

SQLite-net for Unity, supports Windows, Linux, macOS, iOS, tvOS, visionOS, Android and WebGL
MIT License
51 stars 5 forks source link

Android - DLL not found when running in a non-development build #2

Closed BallistiX09 closed 8 months ago

BallistiX09 commented 8 months ago

I've switched over to this package from SQLite4Unity3d and it's been a fantastic drop-in replacement so far, but I'm running into an issue on Android where the DLL file isn't loading correctly:

DllNotFoundException: Unable to load DLL 'gilzoide-sqlite-net'. Tried the load the following dynamic libraries: Unable to load dynamic library 'gilzoide-sqlite-net' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "gilzoide-sqlite-net" not found

This only seems to happen on release builds, whenever I switch to a development build the issue disappears entirely. Specifically, this seems to be triggered when calling new SQLiteConnection, providing a path to the database file. Checking in Android Logcat, I'm not seeing any errors before that point which seem to be related.

Any advice would be appreciated!

gilzoide commented 8 months ago

Hi @BallistiX09 , thanks for the report! That's weird, I can't think of any reason why development builds would work, but release builds would not 🤔 One thing you could do is opening the built APK and check if the gilzoide-sqlite-net.so libraries are present for your device's architecture. If not, or if the name of the library got changed somehow, there might be something in the build process messing with it.

I'll try building a sample project here and see how it goes, will let you know whatever I find.

gilzoide commented 8 months ago

Ok, so I was able to replicate the problem here: development builds for Android work, while release builds do not.

After some testing, I think I found the problem: the library file name needs to have the "lib" prefix in release builds. This seems like a bug in Unity, to support files named "myplugin.so" in development builds, but requiring the name "libmyplugin.so" in release builds. At least adding the prefix works in both builds, so I'll just rename the files and it should just work 🤷‍

Thank's again for the report, I'll let you know when the fix is ready.

gilzoide commented 8 months ago

I release the fix as version 1.0.0-preview5, you can update the package to the newest version and this problem should be fixed. Feel free to reopen the issue if it still persists.

Cheers \o/

BallistiX09 commented 8 months ago

That's perfect, that seems to have sorted it! Thanks so much for getting on that so quickly! Doesn't surprise me at all that it was basically a Unity bug all along, that seems all too common with Unity these days haha!

gilzoide commented 8 months ago

Thanks for testing and reporting back, I really appreciate it.

Doesn't surprise me at all that it was basically a Unity bug all along, that seems all too common with Unity these days haha!

Yeah, no surprises here =P

I'll look into their bug report page later to see if there is any bug opened about this, or else create a new one.