提问人:FunkSoulBrother 提问时间:5/24/2022 最后编辑:Sunderam DubeyFunkSoulBrother 更新时间:6/16/2022 访问量:615
Android Gradle 插件 7.2 忽略了 Android 应用构建过程中添加的 proguard 文件
Android Gradle Plugin 7.2 ignores added proguard file in Android App build process
问:
我有一个为 Android 应用程序项目编写的插件。除此之外,此插件还为所有正在构建的 ApplicationVariants 添加了一个自定义规则文件。Gradle
ProGuard
在引入 Android Gradle 插件之前,它一直运行良好。由于我开始使用 AGP 7.2 编译我的应用程序 - 插件添加的 ProGuard 文件被忽略。7.2
Code
:
project.android.buildTypes[<variant.buildType.name>].proguardFile = new File(<custom Proguard rules file path>)
这在 AGP <= 7.0 中工作,没有任何问题。生成过程的日志中没有异常。
我尝试了另一种方法并得到了相同的结果:我尝试使用脚本添加一个 ProGuard 文件(根本不使用插件) - 但结果是一样的 - 这个文件被忽略了。
这是我添加的代码:build.gradle
afterEvaluate {
for (def buildType : project.android.buildTypes) {
buildType.proguardFile file(< full path>)
}
}
有什么想法吗?
答:
1赞
Martin Zeitler
5/26/2022
#1
在 Groovy 中,该值可以设置为:android.defaultConfig
// this sets one file
android.defaultConfig { config ->
proguardFile new File("../general.pro")
}
// this adds an additional file
android.defaultConfig { config ->
proguardFiles.add(new File("../general.pro"))
}
// proof of concept
android.buildTypes { buildType ->
println buildType
}
这发生在 之前,这意味着早期。:prepareKotlinBuildScriptModel
评论
afterEvalute