Android mk 第三方jar编译出现 Lambda coming from jar file need their interfaces on the classpath to be compi

项目场景:

项目的第三方网络库升级新版本,替换就版本的jar


问题描述

老项目升级第三方okhttp 3.14.9 jar 出现编译失败:

build out/target/common/obj/JAVA_LIBRARIES/lib-okhttp-3.14.9_intermediates/classes.jack
FAILED: out/target/common/obj/JAVA_LIBRARIES/lib-okhttp-3.14.9_intermediates/classes.jack
/bin/bash -c "(mkdir -p out/target/common/obj/JAVA_LIBRARIES/lib-okhttp-3.14.9_intermediates/classes.jack.tmpjill.res ) && (unzip -qo vendor/tpv/apps/tpvRemoteControl/app/src/main/libs/okhttp-3.14.9.jar -d out/target/common/obj/JAVA_LIBRARIES/lib-okhttp-3.14.9_intermediates/classes.jack.tmpjill.res ) && (find out/target/common/obj/JAVA_LIBRARIES/lib-okhttp-3.14.9_intermediates/classes.jack.tmpjill.res -iname \"*.class\" -delete ) && (JACK_VERSION=4.31.CANDIDATE out/host/linux-x86/bin/jack @build/core/jack-default.args    -D jack.import.resource.policy=keep-first -D jack.import.type.policy=keep-first -D jack.android.min-api-level=1 --import vendor/tpv/apps/tpvRemoteControl/app/src/main/libs/okhttp-3.14.9.jar --import-resource out/target/common/obj/JAVA_LIBRARIES/lib-okhttp-3.14.9_intermediates/classes.jack.tmpjill.res --output-jack out/target/common/obj/JAVA_LIBRARIES/lib-okhttp-3.14.9_intermediates/classes.jack ) && (rm -rf out/target/common/obj/JAVA_LIBRARIES/lib-okhttp-3.14.9_intermediates/classes.jack.tmpjill.res )"

原因分析:

Lambda coming from jar file need their interfaces on the...

提示无法支持lambda表达式写法,其中 jack.android.min-api-level=1 关键所在,由于编译的android api level导致无法支持 lambda写法导致编译不通过


解决方案:

问题找到,只要找到对应的修改 jack.android.min-api-level 版本就行。

这边参考Android O Jack预编译静态jar编译报错解决_wd623894174的博客-CSDN博客 

LOCAL_MIN_SDK_VERSION 默认值 1

其中

LOCAL_STATIC_JAVA_LIBRARIES := lib-okhttp-3.14.9 

修改前:



include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := lib-okhttp-3.14.9/libs/okhttp-3.14.9.jar

include $(BUILD_MULTI_PREBUILT)

修改后:

include $(CLEAR_VARS)

LOCAL_MODULE := lib-okhttp-3.14.9
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := libs/okhttp-3.14.9.jar
LOCAL_UNINSTALLABLE_MODULE := true
LOCAL_MIN_SDK_VERSION := 24

include $(BUILD_PREBUILT)

这样修改可通过编译,指定了 LOCAL_MIN_SDK_VERSION 24 可根据需要版本修改

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值