How to generate native jni lib inside APK in Soong Build, currently it is getting generated in system/lib64 but i want it to be packaged within APK

487 views
Skip to first unread message

MaHeMa

unread,
Jul 9, 2024, 11:55:06 AMJul 9
to Android Building
it cannot be device specific as my lib depends on other system libs too

Please guide me how to do it

MaHeMa

unread,
Jul 22, 2024, 1:05:40 PMJul 22
to Android Building
Dear All,

I am writing to request guidance on dynamically generating a native JNI library and bundling it inside an APK using the Soong build system. Currently, the library is generated in the system lib64 folder, but the requirement is to include the library within the APK.

Could you please provide detailed instructions or confirm if this is feasible with Soong build? Any assistance or documentation on achieving this would be greatly appreciated.

Thank you for your support.

Dan Willemsen

unread,
Jul 23, 2024, 3:59:27 PMJul 23
to android-...@googlegroups.com
The build system will install an APK with a correct layout for the platform to use for their particular use case, just be sure to specify them as `jni_libs: [...]` dependencies for the app. Manually changing that shouldn't be necessary, though you may be able to adjust this behavior with `use_embedded_native_libs: true`. This does not adjust what libraries your APK can use, which is controlled by the platform. If you specify `jni_libs` of platform-only libraries, those will be copied into your APK, not shared with the system.

If your intent is to take that APK and use it elsewhere, you really should be building with `tapas` instead of `lunch` to build a generic APK. That changes a handful of behaviors, including this one.

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/fef504fb-536b-407b-b81a-fe062bb77bdcn%40googlegroups.com.

MaHeMa

unread,
Jul 24, 2024, 1:06:32 PMJul 24
to Android Building
Thank you for the response Dan,

I already have 'jni_libs:[...]' property set to native lib in 'android_app', but still shared lib is generated
i set the property `use_embedded_native_libs: true` as well, along with native jni lib, it also embeds other native libraries which actually increased the APK size

is there a way where i can only embed the my jni lib and discard other libraries. (Also, any 'genrule' possible to access the library output path 'out/product/....so' and include it as cc_prebuilt_library_shared)

Can you please elaborate more on below point, what is platform-only library here.
My native jni lib is actually dependent on other system shared libraries

"If you specify `jni_libs` of platform-only libraries, those will be copied into your APK, not shared with the system."

Regards,
Madhusudan
Reply all
Reply to author
Forward
0 new messages