7

We are trying to develop a custom ROM using AOSP's master branch. We have successfully built and run the compiled image on the emulator provided by AOSP. Now we are trying to add an application in the AOSP so that the AOSP branch compiles and runs with the application present in it, that means when we run the android version our newly added application will act as a default/system application.

We have tried doing that using following steps, but have failed:

  1. Place the App_name folder to /packages/apps
  2. Add Android.mk to /packages/apps/App_name/
  3. Add App_name entry to /build/target/product/core.mk PRODUCT_PACKAGES := \ ... \ SomeApp \ App_name

Note: App_name is the application folder that is developed using android studio and is present the Android-Studio Projects folder.

After performing these steps we compile the entire source code/AOSP and eventually the compilation fails.

Could someone please help me out??

warl0ck
  • 3,356
  • 4
  • 27
  • 57
  • could you share the compilation error you are getting ? – warl0ck Jan 07 '18 at 13:50
  • including ./packages/apps/MyApplication1/Android.mk ... ./packages/apps/MyApplication1/Android.mk:6: error: FindEmulator: find: `packages/apps/MyApplication1/src': No such file or directory 19:44:59 ckati failed with: exit status 1 @warl0ck This is the error that I received. – Komal Deolalkar Jan 07 '18 at 14:15
  • as the error says `packages/apps/MyApplication1/src` its unable to find the `src` folder in the application you have put. – warl0ck Jan 07 '18 at 14:42
  • if you would go to [sample app](https://android.googlesource.com/platform/packages/apps/Car/Media/+/master) link from aosp source code this is how you are supposed to put your application including the andoid.mk file – warl0ck Jan 07 '18 at 14:46
  • Thanks for sharing the link. Also I developed the 'MyApplication1' using android studio, wherein the structure of application folder is deferring to the one which you shared. Could you please tell me which IDE did you used to develop the application. – Komal Deolalkar Jan 07 '18 at 16:52
  • I use android studio only. Its just you have to place the app in that format for it to pick up. If it worked, let me know I'll post it as answer as well. – warl0ck Jan 07 '18 at 17:05
  • Okay I will try and let you know! Thanks. Also can you share your email id so that we can reach out to you for further help? – Komal Deolalkar Jan 07 '18 at 17:25
  • Tried [Android AOSP - adding app to /packages/apps](https://stackoverflow.com/questions/24857285/android-aosp-adding-app-to-packages-apps/40494023#40494023)? – Onik Jan 12 '18 at 21:41
  • Thanks! Could you please share the link of the app that you added? – Komal Deolalkar Jan 15 '18 at 14:11
  • There is no link. It was my app added to AOSP. – Onik Jan 15 '18 at 17:38
  • Related: https://stackoverflow.com/questions/10579827/how-do-i-add-apks-in-an-aosp-build?rq=1 | https://stackoverflow.com/questions/10579827/how-do-i-add-apks-in-an-aosp-build?rq=1 – Ciro Santilli OurBigBook.com Jun 21 '20 at 21:03

1 Answers1

9

For adding a default application to AOSP , You should create a directory with arbitrary name in packages/apps (name of directory doesn't matter) , then you should put necessary code and resources in it . Notice AOSP build system doesn't use Gradle ,hence you don't need to copy gradle build files (like build.gradle and setting.gradle and etc).

For a typical app you should create these directories :

  • src : place your java codes here .
  • res : place your resources directory for examle drawable , layout , ...
  • assets : if your project has any assests file , place them in this folder

Your AndroidManifest.xml file should be added in top of your directory.After placing your code and resources , create an Android.mk file and write the following lines in it :

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_PACKAGE_NAME := <Name of your app>

LOCAL_SDK_VERSION := current

LOCAL_SRC_FILES := $(call all-java-files-under, src)

# Include libraries

LOCAL_JAVA_LIBRARIES := <Java lib dependencies>

LOCAL_STATIC_JAVA_LIBRARIES := android-common

LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4

LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res

LOCAL_ASSETS_DIR := $(LOCAL_PATH)/assets

LOCAL_AAPT_FLAGS := --auto-add-overlay

LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat

include $(BUILD_PACKAGE)
  • LOCAL_PACKAGE_NAME is name of your app (for examle camera , app1 , ...) ,you should add this name to /build/target/product/core.mk (no folder name , folder name is not important) .

  • LOCAL_SRC_FILES is pointer to Java codes.

  • LOCAL_JAVA_LIBRARIES : if your project has java lib dependency , reference to it here.

  • LOCAL_RESOURCE_DIR is address of res directory

  • LOCAL_ASSETS_DIR is address of assets directory

Finally build your app and add it to system image . use these commands

make <name of your app>
make snod

<name of your app> is value of LOCAL_PACKAGE_NAME in your Android.mk file. You don't need to build whole AOSP build tree using something like make -j8 . Just build your app and add it to system image. Default applications are placed in read only system partition.

ofskyMohsen
  • 1,121
  • 1
  • 12
  • 26