Hello Guys !!! Hope You are doing well.
Today I am going to discuss How to add .so file in Android AOSP source code external folder.
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
* If .so files in your current app lib folder then path is lib/your_so_file.so
Today I am going to discuss How to add .so file in Android AOSP source code external folder.
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/frameworks/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
If you want to add .so files directly in your app, Then add below flag in your Android.mk file
You find Framework Android.mk file on following location
/android_aosp_sourcecode_download_folder/frameworks/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
If you want to add .so files directly in your app, Then add below flag in your Android.mk file
LOCAL_PATH := $(call my-dir) | |
include $(CLEAR_VARS) | |
LOCAL_MODULE := AndroidMediaShell | |
LOCAL_PRIVILEGED_MODULE := true | |
LOCAL_MODULE_TAGS := optional | |
LOCAL_MODULE_CLASS := APPS | |
LOCAL_SRC_FILES := app/$(LOCAL_MODULE).apk | |
LOCAL_PREBUILT_JNI_LIBS := (complete_path*)lib/your_lin_so_file.so | |
LOCAL_MODULE_TARGET_ARCH := arm or arm64 or x86 | |
LOCAL_CERTIFICATE := PRESIGNED | |
LOCAL_OVERRIDES_PACKAGES := | |
include $(BUILD_PREBUILT) |
* If .so files in your current app lib folder then path is lib/your_so_file.so
Thanks
Saurabh
Happy Coding!!!!
Hello Saurabha sharma,
ReplyDeleteI have generated .so files by building third party SDK(which is c++) with NDK. With the build success it is created lib folder with arm64-v8a,armeabi-v7a , mips, mips64,x86,x86_64 .which indicated it's created .so files for different platfroms. Now i want to include these .so files inside my AOSP framework. AS you said , how can include all my .so files in AOSP?
If i understood your post correctly, I should create exlib folder in AOSP and copy all the folder which have .so files for different platform.
Hi Madhu,
ReplyDeleteYes, You are correct. You have to create a folder(suitable name for your so) inside external folder of AOSP source code(/android_aosp_sourcecode_download_folder/external/yourFolder). After creating folder copy your .so and then create an Android.mk file (just like my above blog) and include your .so in it.
Hope It will help you. Feel free to ask any more doubt.
Thanks
Saurabh
build/make/core/binary.mk:1245: error: external/platform_external_libgpiod/Android.mk: platform_external_libgpiod: Unused source files: libgpiod.so.
Delete15:15:03 ckati failed with: exit status 1
what should i need to do now,I am facing this issue.
Very useful information that you have shared and it is very useful to me.Thanks for sharing the information with us.
ReplyDeletebest mobile app development company in chennai
Very useful information that you have shared and it is very useful to me.Thanks for sharing the information with us.
ReplyDeleteios app development company in chennai
I am not finding the Android.mk file at
ReplyDelete/android_aosp_sourcecode_download_folder/frameworks/base/core/jni/
Any one suggest here
Same Here. Anyone can help ?
Delete