I have a scenario that is to link in a Java static library built from an Android.mk file to complete the whole AOSP image build in Android P. The build system somehow is not versatile enough to discover the static library built from other project using the Android.mk. Here is an example:
1) Android.mk file at the "package/app/MyLibs"
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libmine
LOCAL_SRC_FILES := \
$(call all-java-files-under, src/main/java) \
$(call all-Iaidl-files-under, src/main/aidl)
ifneq ($(filter 28,$(PLATFORM_SDK_VERSION)),)
LOCAL_PRIVATE_PLATFORM_APIS := true
else
LOCAL_SDK_VERSION := current
endif
LOCAL_STATIC_JAVA_LIBRARIES := libgson
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
include $(BUILD_STATIC_JAVA_LIBRARY)
2) Android.bp at "frameworks/base/services/devicepolicy"
java_library_static {
name: "services.devicepolicy",
srcs: ["java/**/*.java"],
libs: [
"conscrypt",
"services.core",
],
static_libs: [
"libmine",
],
}
3) Build message:
error: frameworks/base/services/devicepolicy/Android.bp:1:1: "services.devicepolicy" depends on undefined module "libmine"