android.mk引用第三方AAR依赖
android.mk引用第三方AAR的基本写法
LOCAL_STATIC_JAVA_AAR_LIBRARIES := \
tuyasmart-iot_sdk \
LOCAL_USE_AAPT2 := true
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages com.tuya.smartai.iot_sdk \
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := tuyasmart-iot_sdk:app/libs/tuyasmart-iot_sdk-1.0.8.6.aar
include $(BUILD_MULTI_PREBUILT)
解压aar文件查看有没有其他依赖
1. 包含.so 文件,32位或者64位
JNI_LIBS :=
$(foreach FILE,$(shell find $(LOCAL_PATH)/app/jni -name *.so), $(eval JNI_LIBS += $(FILE)))
LOCAL_PREBUILT_JNI_LIBS := $(subst $(LOCAL_PATH),,$(JNI_LIBS))
LOCAL_MULTILIB := 32
2. 包含其他jar,解压获取aar引用jar
LOCAL_STATIC_JAVA_LIBRARIES := \
fastjson-1.1.67.android \
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += core_3.0.1:app/libs/core_3.0.1.jar
3. 同时引用多个aar,且包含的.so有32,有64时,以32为例,内置到/system/lib
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
LOCAL_JNI_SHARED_LIBRARIES := \
libmarsxlog \
libtuya_iot_android \
libc++_shared
LOCAL_MULTILIB := 32
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE := libmarsxlog
LOCAL_SRC_FILES := app/jni/armeabi-v7a/libmarsxlog.so
LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
LOCAL_MULTILIB := 32
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE := libc++_shared
LOCAL_SRC_FILES := app/jni/armeabi-v7a/libc++_shared.so
LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
LOCAL_MULTILIB := 32
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE := libtuya_iot_android
LOCAL_SRC_FILES := app/jni/armeabi-v7a/libtuya_iot_android.so
LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
LOCAL_MULTILIB := 32
include $(BUILD_PREBUILT)