Android.mk Include other projects

2020-05-24 10:53发布

问题:

Explanations

The goal of my question is to know how to create a Android.mk (makefile) that can build and run, this structures of project below.

  1. Library (is library on eclipse)
    • [/data/projectLibrary/]
  2. Project (Interface)
    • Contains 1 statics libraries (lib1.jar)
    • Depend of Library above
    • [/data/projectUI/]
  3. Project (Service)
    • Contains 2 statics libraries (lib1.jar, lib2.jar)
    • [/data/projectService/]

Questions

  1. I should have one Android.mk for each "project"?
  2. Or i should have one Android.mk that includes all the other "projects"?

Android MK (Service)

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_STATIC_JAVA_LIBRARIES := android-common 
LOCAL_STATIC_JAVA_LIBRARIES += jsr305 
LOCAL_STATIC_JAVA_LIBRARIES += android-common-chips 
LOCAL_STATIC_JAVA_LIBRARIES += lib1 
LOCAL_STATIC_JAVA_LIBRARIES += lib2

LOCAL_JAVA_LIBRARIES += telephony-common mms-common

LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SRC_FILES += $(call all-java-files-under, ../projectLibrary/src)

LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR += ../projectLibrary/res

# Include res dir from chips
chips_dir := ../../../frameworks/ex/chips/res
res_dirs := $(chips_dir) res
$(shell rm -f $(LOCAL_PATH)/chips)
LOCAL_RESOURCE_DIR += $(addprefix $(LOCAL_PATH)/, $(res_dirs))

LOCAL_AAPT_FLAGS := --auto-add-overlay 
LOCAL_AAPT_FLAGS += --extra-packages com.android.ex.chips

LOCAL_REQUIRED_MODULES := SoundRecorder

LOCAL_PROGUARD_FLAG_FILES := proguard.flags

LOCAL_CERTIFICATE := myCertificate

LOCAL_PACKAGE_NAME := MyAppName    

include $(BUILD_PACKAGE)

# make the jni
include $(call all-makefiles-under, jni)

# make the static libs
include $(CLEAR_VARS)    
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := lib1:libs/lib1.jar
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := lib2:libs/lib2.jar    
include $(BUILD_MULTI_PREBUILT)

# make the other makefiles, if necessary
include $(call all-makefiles-under, $(LOCAL_PATH))

Others

I already looked for it on the web,

  • http://www.kandroid.org/online-pdk/guide/build_cookbook.html
  • http://www.gdgankara.org/2011/12/29/understanding-android-makefile-android-mk/
  • :(

[]'s

回答1:

  1. No. It needn't.
  2. Yes. You can reference to the aosp source under "packages/apps/Dialer". It is just meets the situation you declare. Dialer includes "packages/app/ContactsCommon" and "packages/app/InCallUI". You'll find that there is no Android.mk under InCallUI's path.