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 的默认配置文件吧


相关推荐
hawk2014bj22 分钟前
Ubuntu 安装 MySQL
android·mysql·ubuntu
_小马快跑_2 小时前
Android 图像合成:玩转 PorterDuff.Mode 的 18 种混合模式
android
_小马快跑_2 小时前
Android | 多种方式实现图片圆角矩形和圆形效果(续)
android
_小马快跑_2 小时前
MaterialShapeDrawable vs CardView:两种方式实现阴影效果对比
android
_小马快跑_3 小时前
玩转ShapeableImageView:实现灵活的自定义形状与边框效果
android
菜鸟xiaowang4 小时前
Android 使用ninja加速编译的方法
android
_一条咸鱼_6 小时前
Android大厂面试秘籍: View 相关面试题深入分析
android·面试·android jetpack
_一条咸鱼_6 小时前
Android 大厂面试秘籍:Hilt 框架的测试支持模块(八)
android·面试·kotlin
匹马夕阳7 小时前
(十三)安卓开发中的输入框、复选框、单选框和开关等表单控件详解
android
yangshuo12818 小时前
WSA(Windows Subsystem for Android)安装LSPosed和应用教程
android·windows·模拟器·lsposed·windows安卓子系统