Search code examples
androidmakefilecompilationandroid-sourcerom

Make app in Android source compile to system/app


I'm trying to learn how to compile an app in android source. The app is just a simple hello world application. I followed instructions from Making an app in the Android Source compile into system/app instead of data/app? and a couple of other sources. But when I make the application the apk file is written to obj/APPS with suffix intermediates instead of system/app and fails to show up in the emulator when I boot up. Please find below the Android.mk file.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := tests 

LOCAL_MODULE_PATH := system/app

LOCAL_UNINSTALLABLE_MODULE := true

LOCAL_SDK_VERSION := current

LOCAL_PACKAGE_NAME := MyApplication

LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-gridlayout
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v13
LOCAL_STATIC_JAVA_LIBRARIES += android-support-design

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

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/appcompat/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/gridlayout/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/design/res

LOCAL_CERTIFICATE := platform

LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat:android.support.v7.gridlayout

include $(BUILD_PACKAGE)
##################################################
include $(CLEAR_VARS)

include $(BUILD_MULTI_PREBUILT)

# Use the following include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))

I make the application by going to the application directory in packages/apps and doing 'mm'. Is there anything I'm missing here?


Solution

  • Find out the BoardConfig.mk and add this :

    PRODUCT_PACKAGES += MyApplication
    

    AOSP build system will build every Android.mk, but only packages defined in BoardConfig will be put into the final product path.