1

I have a simple aar file I would like to include as a prebuilt library to deploy with the AOSP build. The goal is to deploy the aar file in system/framework so that 3rd party developers can utilise it.

Running mm on the same folder as my Android.mk file does exactly what I am expecting, including the creations of intermediates in obj/JAVA_LIBRARIES and the addition of the file in the PRODUCT/system/framework folder.

However, when I run /m to build the image, the above files are not created and as a result the files are missing from the image.

Placing an on purpose error in my Android.mk and testing a full build does through an error, so my Android.mk is correctly being used in the main build.

I have also added the aar module name in the PRODUCT_BOOT_JARS to ensure the class path is updated to allow development and running of APKs developed with these. Just mentioning, although I do not think it plays a role here (past AOSP builds with jar files worked fine without it for deploying at least)

My Android.mk

# include $(CLEAR_VARS)
# LOCAL_MODULE := mylib
# LOCAL_SRC_FILES := mylib.aar
# LOCAL_MODULE_CLASS := JAVA_LIBRARIES
# LOCAL_MODULE_SUFFIX := .aar
George
  • 1,224
  • 12
  • 21

1 Answers1

1

I think you need to add your module to PRODUCT_PACKAGES variable in makefile, ex:

PRODUCT_PACKAGES += \
    ... \
    mylib

The make file you can modify to add your module maybe build/make/target/product/base.mk or build/target/product/core.mk or some other files depend on your custom build system.

TuanPM
  • 685
  • 8
  • 29
  • Answer accepted it works, although for other I should point out that distributing an aar is completely pointless (to some extent) due to the fact that you cannot dynamically load anything from it. See https://stackoverflow.com/questions/48716303/how-to-load-class-dynamically-from-aar-file-with-dexclassloader – George Sep 28 '20 at 14:08