objectbox / objectbox-java

Android Database - first and fast, lightweight on-device vector database
https://objectbox.io
Apache License 2.0
4.41k stars 304 forks source link

[android] objectbox binaries with shared libc++ #1009

Open andrew-ld opened 3 years ago

andrew-ld commented 3 years ago

my application includes other native binaries that depend on libc++, it would be nice if you distributed objectbox binaries without libc++ statically linked so as to reduce the binary size and ram usage.

Describe the solution you'd like android ndk allows you to switch between static and dynamic libc++ in a simple way https://developer.android.com/ndk/guides/cpp-support

greenrobot-team commented 3 years ago

Thanks for the suggestion. However the docs you link specifically warn against using the shared runtime for JNI libraries distributed through an AAR, like ObjectBox for Android does.

Caution: JNI libraries distributed with Java AARs must not use the shared runtime to avoid conflicting with other libraries and the app.

https://developer.android.com/ndk/guides/cpp-support#shared_runtimes

So I don't think this is possible?

andrew-ld commented 3 years ago

yes, I am aware of the drawbacks of having multiple libraries sharing the same libc++ shared library, especially if the final developers are not careful to build all libraries with the same version of ndk and libc++.

Personally, I manually rebuild each library with native code for my app and it's a pity to have done all this work on so many libraries and stay with static libc++ only for objectbox.

tldr: So I don't think this is possible? is possible but only not recommended if you do not know what you are doing.