aar support in Android.mk
Kostiantyn Luzan's answer has a problem. After compile, the resources in the aar will be added to my main package's R file, but not in the aar package's R file. For example, the aar's package name is my.aar, the main project's package name is my.main. The aar has a string named "string_in_aar". After compile, the strings id is my.main.R.string_in_aar rather than my.aar.R.string_in_aar. This makes the apk crash, because the code in the aar uses my.aar.R.string_in_aar.
The solution is use: LOCAL_AAPT_FLAGS += --extra-packages {aar package name}. You will get two R file. They has the some content. One's package is the main package, the other is the aar package.
You should add following blocks into your Android.mk
LOCAL_STATIC_JAVA_AAR_LIBRARIES:= <aar alias>
.
.
.
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := <aar alias>:libs/<lib file>.aar
include $(BUILD_MULTI_PREBUILT)
Please also be aware of satisfy minSdkVersion required by library into your manifest file.