android 4.4/5.1上使用aar的問題

在Android6.0上能夠使用LOCAL_STATIC_JAVA_AAR_LIBRARIES。build腳本會把指定的aar解壓縮到臨時目錄,並將class.jar和res添加到對應的變量。android

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解壓縮後添加到你的工程,並使用下面相似的語句:ui

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
相關文章
相關標籤/搜索