android 4.4/5.1上使用aar的问题

在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
上一篇:微信小程序Echarts 二次渲染失败 及 组件监听父页面传递值的变化 及 wx.navigateBack 目标页面Onload 不加载问题


下一篇:Android_Menu_PopupMenu