I need to build an application with android.mk in aosp build tree. I have a custom .arr lib with some resources like drawables,strings..etc, Which resides in the following folder apps/libs/mylib.aar
Anyone can tell me how to include the aar in the android aosp build and use that aar resources in another applications. I already tried the following method described here in Stackoverflow.
https://stackoverflow.com/questions/31205856/aar-support-in-android-mk
Android.mk of my application is looked like
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_PACKAGE_NAME := TestSampleAarLib
LOCAL_STATIC_JAVA_AAR_LIBRARIES:= sampleaarlib
LOCAL_STATIC_ANDROID_LIBRARIES += android-support-v7-appcompat
LOCAL_STATIC_ANDROID_LIBRARIES += android-support-v7-gridlayout
LOCAL_STATIC_ANDROID_LIBRARIES += android-support-v13
LOCAL_USE_AAPT2 := true
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages com.myaar.sample.lib
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_TAGS := optional
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MANIFEST_FILE := AndroidManifest.xml
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := sampleaarlib:libs/sampleaarlib.aar
include $(BUILD_MULTI_PREBUILT)
If anyone have idea about using resources from aar in AOSP Please share.
Thanks in advance.
To add resources from the aar file, please add the following in your android.mk file.
LOCAL_RESOURCE_DIR +=$(call intermediates-dir-for,JAVA_LIBRARIES,<aar_file_name>,,common)/aar/res
Tested and verified in the Android 8.1 version.
NB: In the latest android versions like 9+ resources automatically merged to the project.