How to add external libraries (a .so file) to godot 4.2 .net project

Godot Version

4.2

Question

Let’s I have an android library such as mylib.so. How can I include it into the exported apk/aab?

1 Like

I’m not sure if it’s possible to use Android specific libraries, but your best bet is either to write a wrapper in the .NET version of Godot with C#, or take a look at this docs page:

Basically I am using sqlite-net (a c# wrapper) for sqlite. In Unity I just need to add the libsqlite3.so and this is correctly placed into the .aab file under …/lib.

Obviously the libsqlite3.so is necessary for the sqlite-net to work (as from Android N).

How can I add the libsqlite3.so file to the godot project in order to have it bundled correctly into the apk/aab?

If you want to use a C# wrapper, you almost definitely need to use the .NET version of Godot as far as I know.

My specific issue is how to add the libsqlite3.so library in the project and have it exported in the apk…

My question remains…

Since in the Godot version you did not specify if you’re using the .NET version or not, I assume you didn’t, I apologize, hence why I suggested using the .NET version, where, if you use a wrapper like that, you can simply include it in your project as a NuGet package, and it’ll be included with your executable on all platforms, including Android. I do not know of any other way to include a library, unless you are willing to compile from source, and use C++ to include it somehow, but I have very limited knowledge on how to do that.

I maybe a bit late but after hours of trial and error. I found a way to do this using custom builds for Android. After following the guide.

You should have the gradle Android project and should export the project to android make sure its set up correctly if not go here.

Now in the “android/build/” folder on root of your project there will be a “libs/” folder inside is where native library will be loaded. Inside of it we have “debug/” and “release/” inside of each of these will be “arm64-v8a/” and “armeabi-v7a/”(now available since 4.4) or what ever cpu architecture you supporting. Simply place your native library in the correct cpu folder the and dllimport artribute should be able to find it and load it.

Also make sure you do this for debug and release so it works for both configurations.
You may want this automated using a python or any other scripting language.

Hopes this helps anyone in the future.