如何从 Proguard(Android 项目)的混淆中排除外部 .jar?

发布于 2024-10-08 19:28:07 字数 77 浏览 0 评论 0原文

当我使用 proguard.cfg 导出 android 项目时,所有引用的 .jar 文件也会被混淆。如何从混淆中排除其中一些 .jar?

When I export android project with proguard.cfg, all referenced .jar files are obfuscated as well. How can I exclude some of that .jars from obfuscation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

〃温暖了心ぐ 2024-10-15 19:28:07

如果您不想编辑 Ant 脚本,可以为这些外部 jar 中的类添加 -keep 选项到 proguard.cfg 中。例如:

-keep class othercode.** { *; }

或者使用包含否定符的正则表达式:

-keep class !mycode.** { *; }

标准 Ant 脚本仍然会将所有引用的 jar 合并到单个输出 jar 中。

If you don't want to edit the Ant script, you can add -keep options to proguard.cfg for the classes in those external jars. For instance:

-keep class othercode.** { *; }

Or with a regular expression containing a negator:

-keep class !mycode.** { *; }

The standard Ant script will still merge all referenced jars in the single output jar though.

孤城病女 2024-10-15 19:28:07

在配置文件中,将 jar 设置为库 jar,而不是输入 jar。这让他们没有受到影响。

-libjars <path/to/jars>

In your config file, set up your jars as library jars instead of input jars. This leaves them untouched.

-libjars <path/to/jars>
凶凌 2024-10-15 19:28:07

使用 proguard maven 插件,我这样做

<inclusion>
   <groupId>foo.bar</groupId>
   <artifactId>foo-bar</artifactId>
   <library>true</library>
   <filter>!META-INF/**</filter>
</inclusion>

导致

<library>true</library> 

外部 jar 在混淆后合并到最终的 jar 中。但这可能会导致清单被覆盖。我还没有弄清楚如何最好地避免这种情况。

Using proguard maven plugin I do it like that

<inclusion>
   <groupId>foo.bar</groupId>
   <artifactId>foo-bar</artifactId>
   <library>true</library>
   <filter>!META-INF/**</filter>
</inclusion>

The

<library>true</library> 

lead to the external jar merged into the final jar after the obfuscation. But this might lead to the Manifest being overwritten. I haven't figured out yet how to avoid that the best way.

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