在Android6.0上可以使用LOCAL_STATIC_JAVA_AAR_LIBRARIES。build脚本会把指定的aar解压缩到临时目录,并将class.jar和res添加到对应的变量。
LOCAL_STATIC_JAVA_AAR_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)) ifdef LOCAL_STATIC_JAVA_AAR_LIBRARIES my_full_libs_manifest_deps += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES), $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/classes.jar) my_full_libs_manifest_files += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES), $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/AndroidManifest.xml) LOCAL_RESOURCE_DIR += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES), $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/res) endif
LOCAL_STATIC_JAVA_AAR_LIBRARIES在Android4.4不存在,但是只要参照上面的步骤就可以了。手动将aar解压缩后添加到你的工程,并使用下面类似的语句:
LOCAL_STATIC_JAVA_LIBRARIES += lib_android_recyclerview LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.recyclerview LOCAL_RESOURCE_DIR += $(addprefix $(LOCAL_PATH)/, android-recyclerview-v7/res) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += lib_android_recyclerview:android-recyclerview-v7/classes.jar
时间: 2024-10-20 18:51:35