I've made a couple attempts to add a single shared object library to an Android 10 build by adapting older instructions here and here.
I added a directory containing the library under /device/vendor/name/ and an Android.mk file using the two-target example.
They have all lead back to the same error:
build/make/core/base_rules.mk:480: error: writing to readonly directory: "system/lib64/libjni_latinimegoogle.so"
Is there a correct/accepted way to do this for 10? Thanks
edit: Android.mk file contents
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libjni_latinimegoogle
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
ifdef TARGET_2ND_ARCH
LOCAL_MULTILIB := both
LOCAL_MODULE_PATH_64 := system/lib64
LOCAL_SRC_FILES_64 := system/lib64/libjni_latinimegoogle.so
LOCAL_MODULE_PATH_32 := system/lib
LOCAL_SRC_FILES_32 := system/lib/libjni_latinimegoogle.so
else
LOCAL_MODULE_PATH := system/lib64
LOCAL_SRC_FILES := system/lib64/libjni_latinimegoogle.so
endif
include $(BUILD_PREBUILT)
The correct way is to specify in the device makefile. The goal was to add gesture typing to a LineageOS 17.1 build - using the Pixel 3XL crosshatch as an example:
in vendor/google/crosshatch/crosshatch-vendor.mk
under PRODUCT_COPY_FILES, add the row to copy the .so library similar to the ones around it, under lib64 (or lib for 32 bit device builds):
PRODUCT_COPY_FILES += \
...
vendor/google/crosshatch/proprietary/lib64/libjni_latinimegoogle.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libjni_latinimegoogle.so \
...
TARGET_COPY_OUT_SYSTEM will direct it to the system partition vs PRODUCT, SYSTEM_EXT, or VENDOR which are also options.
Finally make sure to add the .so file where it needs to be copied from locally, under vendor/google/crosshatch/proprietary/lib64
Gesture typing will be enabled in the next build. This is also working with LineageOS 18.1