为什么需要两个proguard规则-保持同一班级 [英] why it needs two proguard rule -keep for same class

查看:131
本文介绍了为什么需要两个proguard规则-保持同一班级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个应用程序中,在同一规则文件中使用的proguard规则中看到了这两个.

In one app, saw these two in proguard rules used in same rule file.

-keep public class com.google.gson.**
-keep public class com.google.gson.** {public private protected *;}

第一个只有班级.第二个括号中有更多详细信息.

first one has only class. second one brackets with some more details.

为什么需要两个规则?第一个不是也适用于班级成员吗?

why it needs two rules? isnt the first one also apply to the class members?

推荐答案

第一个选项( -keep public class com.google.gson.** )将公共包名称保留在包中com.google.gson和所有基础软件包,但不包括其成员.

The first option (-keep public class com.google.gson.**) will preserve the public class names in the package com.google.gson and all underlying packages but not their members.

使用第二个选项,等效于 -keep公共类com.google.gson.** {*;} ,您将保留公共类名称及其成员.注释掉第一个-keep选项应该没有什么区别.

With the second option, which is equivalent to -keep public class com.google.gson.** { *; } you will preserve the public class names together with their members. Commenting out the first -keep option should make no difference.

您可以使用 ProGuard游乐场来查看ProGuard配置对类的影响在您的jar/apk中.我已经使用这些-keep选项创建了一个,您可以通过单击链接打开它.

You can use the ProGuard Playground to see the effect of your ProGuard configuration on the classes inside your jar/apk. I created one already with these -keep options which you can open by clicking the link.

这篇关于为什么需要两个proguard规则-保持同一班级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆