How to Add Pre-built App (System App) in AOSP source code

semw picture semw · Mar 2, 2020 · Viewed 7.6k times · Source

I was trying to add an APK in AOSP version 10 as system application. I have followed the procedure mentioned in almost different links which is here Add apk in AOSP but nothing worked. The process mentioned in this link and the steps I followed are:

  1. Put my Apk in Aosp_root/packages/apps/my-app-folder/my-app.apk
  2. Write Android.mk of my-app.apk in /my-app-folder

Code of Android.mk

    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    
    LOCAL_MODULE_TAGS := optional
    
    LOCAL_MODULE := Signal
    
    LOCAL_CERTIFICATE := platform
    
    LOCAL_SRC_FILES := Signal-website-universal-release-4.55.8.apk
    
    LOCAL_MODULE_CLASS := APPS
    
    LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
    
    include $(BUILD_PREBUILT)
  1. Then in step 3 to add PRODUCT_PACKAGES in core.mk or common.mk I could not find both specified files (core.mk or common.mk) in specified directory (build/target/products). But I found gsi-common.mk file in build/target/product folder and found PRODUCT_PACKAGES in this file and added directory of my-app in it.

here is code of gsi-common.mk.

   `PRODUCT_PACKAGES += \
    messaging \
    PhotoTable \
    WAPPushManager \
    WallpaperPicker \
    Signal \`
  1. After rebuilding AOSP for aosp-root and flashing it on device nothing has changed, my-app.apk was not added. Then i used mm command in packages/apps directory and it built my-app.apk and it was added in aosp_root/out/target/product/taimen/system/app. After it I run make snod command to re-generate system image and it was created. When I flashed this image in my Pixel device it stucks on Google logo and also shows operating system is corrupt before it shows google logo.

Can you tell me what I am missing or which step is wrong ?

Answer

Ketan sangle picture Ketan sangle · Nov 20, 2020

Answering this for Android 11 and Android 8.1

Create a folder for your application in <AOSP-root-directory>/package/apps/<yourAppFolder>

Inside yourAppFolder create an Android.mk file with below content

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := < your app folder name >

LOCAL_CERTIFICATE := platform

LOCAL_SRC_FILES := < app apk filename >

LOCAL_MODULE_CLASS := APPS

LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

include $(BUILD_PREBUILT)

Put your apk file in the same folder.

Now we've to include the apk in the system image to do that, to do that we've to mention the module name in the PRODUCT_PACKAGES list in the file:

For android 11 - aosp-root-dir/build/target/product/handheld_system.mk

For android 8.1 - aosp-root-dir/build/target/product/core.mk