I created a custom system image and put an additional APK into system/app. This kinda works, I can run the app, however native libraries are not getting loaded (loadLibrary(
Follow these steps
Check libraries of prebuild APK. Install app in device (pm install) and then open android studio(apk installed device attached with pc), Click on View->Tools windows-> Device file explorer. It will open device explorer in right side, there go to data folder and check libraries in your app package name.
copy libraries and create a folder in aosp_source/external/yourlibfolder and paste your libraries there.
Go to build/target/product and write this code in your relevant make file.
external/yourlibfolder/yourlibname.so:system/lib/yourlibname.so \
external/yourlibfolder/yourlibname.so:system/lib64/yourlibname.so \