importing custom SO file to AOSP

后端 未结 2 1322
旧时难觅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 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

提交回复
热议问题