AGP8+ android.useNewApkCreator‘ is deprecated 打包失败

问题

新建一个项目,默认使用最新版的 AGP 和 Gradle,打包构建立马失败!

错误日志

Caused by: com.android.builder.errors.EvalIssueException: The option 'android.useNewApkCreator' is deprecated.

java 复制代码
An exception occurred applying plugin request [id: 'com.android.application', version: '8.3.0']
> Failed to apply plugin 'com.android.internal.application'.
   > com.android.builder.errors.EvalIssueException: The option 'android.useNewApkCreator' is deprecated.
     The current default is 'true'.
     It was removed in version 8.0 of the Android Gradle plugin.

全局搜索,当前项目确实没有配置该属性 android.useNewApkCreator,这属性到底是哪里来的?

解决

我们都知道,project.properties 属性值主要数据来源是 gradle.properties 配置文件。

我们通过在 build.gradle 文件输出属性配置,确实是有该配置,并且值是 false

看起来怎么与这两句话意思相反呢?真是差点搞不懂了~

① The current default is 'true'. 【实际输出确是 false】
② It was removed in version 8.0 of the Android Gradle plugin. 【removed 了,为什么输出还有值?】

groovy 复制代码
val newApkKey = "android.useNewApkCreator"
val containsNewApkKey = project.properties.containsKey(newApkKey)
println("containsNewApkKey:${containsNewApkKey}")

for (p in project.properties) {
    println("项目属性:${p.key} = ${p.value}")
}

根据上述第二点 ② 如果不是系统内预置,我们确认是否存在某个gradle.properties 文件内配置了该属性,并且这个文件是每个项目都会读取的?

果不其然,通过磁盘全局搜索发现一个醒目了路径下存在这个文件,打开一看正如我所想,注释掉之后再运行不再报错了~

#android.useNewApkCreator=false

这或许是 AS 的默认配置文件吧


相关推荐
太空漫步111 小时前
android社畜模拟器
android
海绵宝宝_4 小时前
【HarmonyOS NEXT】获取正式应用签名证书的签名信息
android·前端·华为·harmonyos·鸿蒙·鸿蒙应用开发
凯文的内存6 小时前
android 定制mtp连接外设的设备名称
android·media·mtp·mtpserver
天若子6 小时前
Android今日头条的屏幕适配方案
android
林的快手7 小时前
伪类选择器
android·前端·css·chrome·ajax·html·json
望佑8 小时前
Tmp detached view should be removed from RecyclerView before it can be recycled
android
xvch10 小时前
Kotlin 2.1.0 入门教程(二十四)泛型、泛型约束、绝对非空类型、下划线运算符
android·kotlin
人民的石头14 小时前
Android系统开发 给system/app传包报错
android
yujunlong391914 小时前
android,flutter 混合开发,通信,传参
android·flutter·混合开发·enginegroup
rkmhr_sef14 小时前
万字详解 MySQL MGR 高可用集群搭建
android·mysql·adb