Android.mk引用aar包
aar是Android Archive檔,在Anroid.mk中使用aar包有三步驟:
1. 先把這些aar模組設定成prebuilt
把aar包下載回來,假設aar包都放在lib目錄內,寫個獨立的Android.mk設為prebuiltinclude $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBARRIES += {aar-package-name-1}:lib/{aar-file-name-1}.aar
LOCAL_PREBUILT_STATIC_JAVA_LIBARRIES += {aar-package-name-2}:lib/{aar-file-name-2}.aar
...
include $(BUILD_MULTI_PREBUILT)
LOCAL_STATIC_JAVA_AAR_LIBRARIES += {aar-package-name-2}
...
LOCAL_AAPT_FLAGS += --extra-packages {aar-class-name-1}
LOCAL_AAPT_FLAGS += --extra-packages {aar-class-name-2}
...
include $(BUILD_MULTI_PREBUILT)
2. 表明加入需要使用aar包
LOCAL_STATIC_JAVA_AAR_LIBRARIES += {aar-package-name-1}LOCAL_STATIC_JAVA_AAR_LIBRARIES += {aar-package-name-2}
...
3. 並加入aar的class名稱
編譯程式才會找的到LOCAL_AAPT_FLAGS += --auto-overlayLOCAL_AAPT_FLAGS += --extra-packages {aar-class-name-1}
LOCAL_AAPT_FLAGS += --extra-packages {aar-class-name-2}
...
留言