Android.mk 引入jar、aar、so文件

引入单个aar和多个jar

diff --git a/Android.mk b/Android.mk
index f6ff7f4..1dd55fe 100644
--- a/Android.mk
+++ b/Android.mk
@@ -2,6 +2,8 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)

 
+LOCAL_STATIC_JAVA_LIBRARIES := jzxing
+LOCAL_STATIC_JAVA_AAR_LIBRARIES:=azxing
 LOCAL_MODULE_TAGS := optional
 LOCAL_CERTIFICATE := platform
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -16,4 +18,13 @@ LOCAL_SYSTEM_EXT_MODULE := true
 LOCAL_SHARED_ANDROID_LIBRARIES := android-support-v7-appcompat
 
 include $(BUILD_PACKAGE)
-
+include $(CLEAR_VARS)
+LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += jzxing:libs/core-3.3.2.jar \
+    libs/core-3.3.2.jar \
+    libs/core-3.3.2-javadoc.jar \
+    libs/core-3.3.2-sources.jar \
+    libs/zxing-android-embedded-3.6.0-sources.jar
+include $(BUILD_MULTI_PREBUILT)
+include $(CLEAR_VARS)
+LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES +=azxing:libs/zxing-android-embedded-3.6.0.aar
+include $(BUILD_MULTI_PREBUILT)

引入多个aar和多个jar

diff --git a/Android.mk b/Android.mk
index f6ff7f4..5fee482 100644
--- a/Android.mk
+++ b/Android.mk
@@ -2,6 +2,10 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
+LOCAL_STATIC_JAVA_LIBRARIES := jzxing
+LOCAL_STATIC_JAVA_AAR_LIBRARIES := azxing \
+    anfc

 LOCAL_MODULE_TAGS := optional
 LOCAL_CERTIFICATE := platform
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -14,6 +18,21 @@ LOCAL_PRIVATE_PLATFORM_APIS := true
 #LOCAL_PRODUCT_MODULE := true
 LOCAL_SYSTEM_EXT_MODULE := true
 LOCAL_SHARED_ANDROID_LIBRARIES := android-support-v7-appcompat

+#LOCAL_STATIC_JAVA_LIBRARIES +=posPrinter
+LOCAL_MANIFEST_FILE := AndroidManifest.xml
 include $(BUILD_PACKAGE)

+include $(CLEAR_VARS)
+LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += jzxing:libs/core-3.3.2.jar \
+    libs/core-3.3.2.jar \
+    libs/core-3.3.2-javadoc.jar \
+    libs/core-3.3.2-sources.jar \
+    libs/zxing-android-embedded-3.6.0-sources.jar \
+    libs/dkcloudid-uart-android-sdk-v1.0.0-beta-sources.jar
+include $(BUILD_MULTI_PREBUILT)
+include $(CLEAR_VARS)
+LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := azxing:libs/zxing-android-embedded-3.6.0.aar  \
+    anfc:libs/dkcloudid-uart-android-sdk-v1.0.0-beta.aar 
+include $(BUILD_MULTI_PREBUILT)

引入so 库

错误方式

++ include $(CLEAR_VARS)
++ LOCAL_MODULE := libserial_port
++ LOCAL_SRC_FILES := libserial_port:libs/arm64-v8a/libserial_port.so \
++    libs/armeabi-v7a/libserial_port.so
++ include $(PREBUILT_SHARED_LIBRARY)

正确方式

TARGET_OUT 指的是:system

#$(shell mkdir -p $(TARGET_OUT)/app/xxx/lib/)
$(shell cp -r $(LOCAL_PATH)/libs/arm64-v8a/* $(TARGET_OUT)/app/xxx/lib/)

TARGET_OUT_SYSTEM_EXT 指的是:system_ext
xxx 指App名称
arm 指32位
arm64 则代表64位
所以我们需要兼容下这两种情况

$(shell mkdir -p $(TARGET_OUT_SYSTEM_EXT)/app/xxx/lib/arm/)
$(shell mkdir -p $(TARGET_OUT_SYSTEM_EXT)/app/xxx/lib/arm64/)
$(shell cp -r $(LOCAL_PATH)/libs/arm64-v8a/* $(TARGET_OUT_SYSTEM_EXT)/app/xxx/lib/arm/)
$(shell cp -r $(LOCAL_PATH)/libs/arm64-v8a/* $(TARGET_OUT_SYSTEM_EXT)/app/xxx/lib/arm64/)

获取路径详解

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

王睿丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值