When are the APKs in system/app being installed?

前端 未结 2 1425
耶瑟儿~
耶瑟儿~ 2021-01-16 12:35

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(

相关标签:
2条回答
  • 2021-01-16 12:58

    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 \ 
    
    • It will add app dependent libraries in AOSP. Now when you add your Pre-built apk in AOSP it will work
    0 讨论(0)
  • 2021-01-16 13:09

    Pre-installed apps on AOSP aren't so much installed as kind of 'copied over'.

    In order to have the prebuilt libs also 'copied over' you have to specify them in your Android.mk.

    You do this by specifying LOCAL_PREBUILT_JNI_LIBS on your Android.mk.

    Here's an example:

    LOCAL_PATH := $(call my-dir)
    
    my_archs := arm x86 arm64
    my_src_arch := $(call get-prebuilt-src-arch, $(my_archs))
    
    include $(CLEAR_VARS)
    LOCAL_MODULE := TestApp
    LOCAL_MODULE_CLASS := APPS
    LOCAL_MODULE_TAGS := optional
    LOCAL_BUILT_MODULE_STEM := package.apk
    LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
    LOCAL_CERTIFICATE := PRESIGNED
    LOCAL_SRC_FILES := TestApp.apk
    
    LOCAL_PREBUILT_JNI_LIBS := \
      @lib/arm64-v8a/libnoise.so
    
    LOCAL_MODULE_TARGET_ARCH := $(my_src_arch)
    
    include $(BUILD_PREBUILT)  
    

    There is a useful tool called genandroidmk which can generate this Android.mk for you automatically:
    https://github.com/northbright/genandroidmk

    0 讨论(0)
提交回复
热议问题