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:
App_name
folder to /packages/appsNote: 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??
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 :
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With