1
votes

I have been trying to add an aar file to my application developed with the AOSP using the following section of my Android.mk:

...
LOCAL_STATIC_JAVA_AAR_LIBRARIES := \
    aar-lib    
LOCAL_AAPT_FLAGS := --auto-add-overlay \
--extra-packages com.mypackage.name

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
    aar-libr:libs/aarname.aar
...

A bunch of immediates are created in the out/target/common/obj/JAVA_LIBRARIES and in the out/target/common/R folder. However, I do not seem to be able to actually import the packages contained in the aar. For example, the aar itself contains a libs folder with a classes.jar archive. But the import statements for contained classes cause errors when building.

I am working with the target sdk version 28. Is there a way to resolve these dependency issues?

1

1 Answers

0
votes

If you tend to use Android.bp for your app, try this approach for defining the library:

android_library_import {
    name: "your-lib-name",
    aars: ["your-lib-file-name.aar"],
    sdk_version: "current",
    min_sdk_version: "28", // optional
}

and add the name defined above in your android_app's static_libs