Extract native libs from prebuilt apk file using Android.mk

3.2k Views Asked by At

I have an APK file with the bundled native libs. When I install them using adb the libraries are correctly created at <path-to_package>/lib/, But I have to integrate my apk to the build system along with the Android.mk file. What I need to add in the make to get the libs extracted on to the target

2

There are 2 best solutions below

7
Mykola Khyliuk On
2
semw On
  • If you have libraries then 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(e.g handhel_system.mk) for each of library. Replace yourlibname with each library name

external/yourlibfolder/yourlibname.so:system/lib/yourlibname.so \
external/yourlibfolder/yourlibname.so:system/lib64/yourlibname.so \ 
  • It will add app dependent libraries in AOSP. Now when you add your Pre-built apk in AOSP it will work

Create a folder in packages/app/yourappfolder and paste APK and make file there

This should be your make file

# Adding Apk as system app in AOSP
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := Appname # It should be your apk name, and folder name should also be same 
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := .apk
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := platform
include $(BUILD_PREBUILT)