objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

[android] objectbox binaries with shared libc++

Open andrew-ld opened this issue 4 years ago • 2 comments

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

andrew-ld avatar Oct 03 '21 14:10 andrew-ld

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?

greenrobot-team avatar Oct 04 '21 09:10 greenrobot-team

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.

andrew-ld avatar Oct 04 '21 13:10 andrew-ld