Flutter:将 Proguard 与 Gradle 7.0.4 结合使用

发布于 2025-01-20 10:57:17 字数 857 浏览 1 评论 0原文

我刚刚更新到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘羡 2025-01-27 10:57:17

从 Gradle 7.0.0 开始,“useProguard”行已被删除。如果没有这个,Flutter 应该会进行混淆,但如果需要,您可以添加 shr​​inkResources 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文