Flutter:将 Proguard 与 Gradle 7.0.4 结合使用
我刚刚更新到 Gradle 7.0.4,在构建时我现在收到错误。
A problem occurred evaluating project ':app'.
No signature of method: build_9gq7rvxos4tcg7upa17qqy1oj.android() is applicable for argument types: (build_9gq7rvxos4tcg7upa17qqy1oj$_run_closure3) values: [build_9gq7rvxos4tcg7upa17qqy1oj$_run_closure3@558fca1c]
由于错误指向我的 app/build.gradle 中的 android{} 标记,我尝试注释掉 android{} 标记的不同部分。 摆脱错误,所以我的问题是我必须在代码中更改什么才能实现这一点。
android {
/* More code */
buildTypes {
release {
signingConfig signingConfigs.release
// These lines seem to have caused the error:
// minifyEnabled true
// useProguard true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
我设法通过注释掉 Proguard:但是,我仍然想使用 proguard 来
I just updated to Gradle 7.0.4 and upon build I now get the error.
A problem occurred evaluating project ':app'.
No signature of method: build_9gq7rvxos4tcg7upa17qqy1oj.android() is applicable for argument types: (build_9gq7rvxos4tcg7upa17qqy1oj$_run_closure3) values: [build_9gq7rvxos4tcg7upa17qqy1oj$_run_closure3@558fca1c]
As the error pointed to the android{} tag in my app/build.gradle I tried commenting out different sections of the android{} tag. I managed to get rid of the error by commenting out Proguard:
android {
/* More code */
buildTypes {
release {
signingConfig signingConfigs.release
// These lines seem to have caused the error:
// minifyEnabled true
// useProguard true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
However, I would still like to use proguard so my question is what I have to change in my code to make this happen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 Gradle 7.0.0 开始,“useProguard”行已被删除。如果没有这个,Flutter 应该会进行混淆,但如果需要,您可以添加
shrinkResources true
。Android R8 是使用 Proguard 的替代方案,具有自己的设置;只要您配置了此功能,您可能就需要考虑切换。
The 'useProguard' line has ben removed, as of Gradle 7.0.0. Flutter should obfuscate without this, but you can add
shrinkResources true
, if you want.Android R8 is an alternative to using Proguard, with its own settings; as long as you're configuring this, you might want to look into switching.