最近项目中使用到aar,需要将aar编译到系统内,翻阅资料,成功引用后特做记录。
aar引用跟普通的第三方jar包引用其实非常类似
LOCAL_STATIC_JAVA_LIBRARIES := imageloader
......
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := imageloader:libs/image-loader.jar
include $(BUILD_MULTI_PREBUILT)
以下为使用aar示例:
1.编译aar(以support library为例)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := recyclerview-v7-25.3.1:libs/recyclerview-v7-25.3.1.aar \
support-v13-25.3.1:libs/support-v13-25.3.1.aar
include $(BUILD_MULTI_PREBUILT)
2.引用aar
LOCAL_STATIC_JAVA_AAR_LIBRARIES := recyclerview-v7-25.3.1 \
support-v13-25.3.1
3.同时使用aar内部的资源
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.recyclerview//此处为aar内部AndroidManifest.xml定义的包名
LOCAL_AAPT_FLAGS += --extra-packages android.support.v13
参考资料:https://stackoverflow.com/questions/31205856/aar-support-in-android-mk