今天就來整理下如果要將 app 放進 aosp 裡面
Android.mk 檔要怎麼寫
最簡單的方式是先將 Module 編譯成 apk 檔
這樣子可以使用 gradle 編譯
dependency 也不用寫在 Android.mk 裡
非常簡單
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) # Module name should match apk name to be installed LOCAL_MODULE := XXXXXXX LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(LOCAL_MODULE).apk LOCAL_MODULE_CLASS := APPS LOCAL_CERTIFICATE := platform include $(BUILD_PREBUILT)
如果因為原始碼管理或是其他原因
你必須要把 Module 的專案原始碼放進 aosp 裡面的話
那麼可以參考一下下面的複雜版本
LOCAL_PATH:= $(call my-dir) # compile time only jar names (for later use) #COMPILE_LIBRARIES := compiler-a compiler-b include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional # Name of the module to build LOCAL_PACKAGE_NAME := XXXXXXX # module src file path LOCAL_SRC_FILES := \ $(call all-java-files-under, java) # path(s) of resources #LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, res) # List of static libraries to include in the package #LOCAL_STATIC_JAVA_LIBRARIES := lib-jar-a lib-jar-b lib-jar-c #LOCAL_STATIC_JAVA_AAR_LIBRARIES := lib-aar-a lib-aar-b lib-aar-c # path of compile time libs #LOCAL_CLASSPATH := $(addprefix $(LOCAL_PATH)/libs/,$(addsuffix .jar, $(COMPILE_LIBRARIES))) # set as privileged application #LOCAL_PRIVILEGED_MODULE := true # use platform key to sign the module LOCAL_CERTIFICATE := platform # proguard enabled setting LOCAL_PROGUARD_ENABLED := disabled include $(BUILD_PACKAGE) ############## JAR/AAR Files #################################### #include $(CLEAR_VARS) # ## pre built all your jar and aar lib for your module ## so you can use the lib name in LOCAL_STATIC_JAVA_LIBRARIES and LOCAL_STATIC_JAVA_AAR_LIBRARIES #LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := lib-jar-a:libs/lib-jar-a.1.0.0.jar \ # lib-jar-b:libs/lib-jar-b.1.0.0.jar \ # lib-jar-c:libs/lib-jar-c.1.0.0.jar \ # lib-aar-a:libs/lib-aar-a.1.0.0.aar \ # lib-aar-b:libs/lib-aar-b.1.0.0.aar \ # lib-aar-c:libs/lib-aar-c.1.0.0.aar # #include $(BUILD_MULTI_PREBUILT)
以上是參考不同範例綜合而成
若有錯誤及建議也希望不吝指教