In Android, can a shared library have a custom file extension instead of .so and still be loaded using loadLibrary?


I'm working on an Android project with C++ native libraries built using CMake. I want to give my shared libraries a custom file extension (e.g. .abc or .xyz) instead of the standard .so.

Most of my application logic lives inside these native shared libraries, and the Java/Kotlin side is a minimal launcher that loads them at runtime.

I understand that System.loadLibrary("foo") is hardcoded to look for libfoo.so and there is no way to override this behavior.

But is there any way to make System.loadLibrary() work with a custom extension and works everything properly as normal application ?

0
Jun 24 at 5:59 AM
User AvatarRohan Pande
#android#java-native-interface#shared-libraries

Accepted Answer

System.loadLibrary on Android always prepends lib and appends .so. That can not be changed. The only alternative is System.load which allows you to specify the full file-name.

User AvatarRobert
Jun 24 at 6:44 AM
0