Reputation: 663
About the Android Shared library.
We added the system shared library to the Android source code with the following code:
Android.bp:
cc_prebuilt_library_shared {
name: "libfilamat-jni",
arch: {
arm64: {
srcs: ["jniLibs/arm64-v8a/libfilamat-jni.so"],
},
arm: {
srcs: ["jniLibs/armeabi-v7a/libfilamat-jni.so"],
},
x86_64: {
srcs: ["jniLibs/x86_64/libfilamat-jni.so"],
},
},
installable: true,
stem: "libfilamat-jni",
relative_install_path: "",
shared_libs: ["liblog"],
strip: {
none: true,
},
}
Same as other files.
product.mk
PRODUCT_PACKAGES += \
libfilamat-jni \
libfilament-jni \
libgltfio-jni \
libfilament-utils-jni
Then, the .so libraries copied to the /system/lib64 and app is working as a System app.
However, if we install over it with adb install command then app stops to access .so file and failing.
I confirmed that if we add .so file's name to the file /system/etc/public.libraries.txt then, problem will be resolved.
However, now I can not find the way to append the file name to the /system/etc/public.libraries.txt with Android.bp, product.mk or some kind of way to do it with the Android build system.
Or, are there any other way to achieve this?
Upvotes: 0
Views: 31
Reputation: 663
Finally, I got the answer.
We can add the file names to following file before build. It will be copied to the /system/etc/public.libraries.txt
when build.
system/core/rootdir/etc/public.libraries.android.txt
product.mk:
LOCAL_PATH := vendor/path-to/my-module-dir
PUBLIC_LIBRARIES_PATH := system/core/rootdir/etc/public.libraries.android.txt
# Maybe file already exists. Therefore, we carefully append it.
$(shell touch $(PUBLIC_LIBRARIES_PATH))
$(shell while read -r line; do \
if ! grep -q "$$line" $(PUBLIC_LIBRARIES_PATH); then \
echo "$$line" >> $(PUBLIC_LIBRARIES_PATH); \
fi; \
done < $(LOCAL_PATH)/etc/public.libraries.txt)
Upvotes: 0