importing custom SO file to AOSP

后端 未结 2 1312
旧时难觅i
旧时难觅i 2021-02-09 19:16

I\'ve built an AOSP system service following this tutorial: http://www.androidenea.com/2009/12/adding-system-server-to-android.html

Now I want to use a pre-compiled .so

相关标签:
2条回答
  • 2021-02-09 19:56

    So the answer was quite simple. I really need to copy my lib to the system image, to the system/lib folder, because the make command doesn't copy it from out/target/product/generic/system/lib to system.img

    the trick is to add this line

      PRODUCT_COPY_FILES += $(LOCAL_PATH)/my_lib.so:system/lib/my_lib.so
    

    to full.mk file. it's location is: android-source/build/target/product also put the my_lib.so near it (as seen by the path)

    if you are planning to run the image on a real device, add this line after the device name definition. f.ex. if you are running on Nexus 4, put it at android-source/device/lge/mako/full_mako.mk

    0 讨论(0)
  • 2021-02-09 20:06

    You can add your prebuilt library in Android AOSP source code and it be a part of your AOSP System Image. I am describing step by step procedure for it.

    Step 1 Create a folder ( let say myLibs) inside external folder of AOSP source code.

    external folder of AOSP source code refers to external open source libraries. That means libraries that the Android platform depend upon but that are not primarily developed and maintained by the Android open source project.

    examples are webkit for the browser, FreeType for fonts, SqlLite for databases and so on. As more features are added to Android, more of these libraries are included in external.

    Step 2 Create a Android.mk file

    Create a Android.mk file inside your folder(let say myLibs) and copy your .so file in it.
    You can use following content for your android.mk file

    # Prebuilt Lib
    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_MODULE := libMyabc # your lib name
    LOCAL_SRC_FILES := libMyabc.so
    # your lib .so file name
    include $(BUILD_SHARED_LIBRARY)
    

    Step 3 Add your library in Framework

    In final step you have to add your library in Android AOSP framework makefile so that it will recognise and build as a part of System image.
    You find Framework Android.mk file on following location
    /android_aosp_sourcecode_download_folder/framenter code hereeworks/base/core/jni/

    Open Android.mk file and add your library in following section
    LOCAL_SHARED_LIBRARIES := \
    You can put your library name in that section example libMyabc \

    That's it... now make it (make -j4) and you find your added so file in following folder
    /android_aosp_sourcecode_download_folder/out/target/product/generic/obj/lib
    with file name like :- libMyabc.so and libMyabc.so.toc
    and you also found it in system/lib folder
    /android_aosp_sourcecode_download_folder/out/target/product/system/lib

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