我有一個Gradle為 Android 應用程式專案撰寫的插件。除其他外 - 此插件將自定義ProGuard規則檔案添加到所有正在構建的 ApplicationVariants。
7.2在引入Android Gradle 插件之前一直運行良好。由于我開始使用 AGP 7.2 編譯我的應用程式 - 插件添加的 ProGuard 檔案被忽略。
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>)
}
}
有任何想法嗎?謝謝!
uj5u.com熱心網友回復:
在 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,這意味著早期。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/482600.html
