我怎么能告诉ProGuard假设一个包没有使用? [英] How can I tell proguard to assume a package is not used?

查看:150
本文介绍了我怎么能告诉ProGuard假设一个包没有使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立的ProGuard我的Andr​​oid项目。我们用一个网状库的一些作品在我们的code和我想使用的Proguard完全删除code的作品,我知道不会被使用。

I'm attempting to set up proguard for my Android project. We use some pieces of a netty library in our code and I'd like to use Proguard to completely remove the pieces of code that I know aren't used.

是否有某种方式告诉ProGuard假设一个包(或类)从未使用过,因此不应该被包含在输出JAR文件?请注意,我的的谈论排除某些混淆code(这是什么 -keep 配置选项做),我米完全谈论的删除的从输出类。

Is there some way to tell proguard to assume a package (or class) is never used and so should not be included in the output JARs? Note that I'm not talking about excluding some code from obfuscation (which is what the -keep configuration options do), I'm talking about completely removing a class from the output.

修改:如下面PST的建议,我试图用 -whyareyoukeeping 参数来确定code路径proguard的用途以确定一个类被使用。它不会改变几十个警告的输出。

Edit: As suggested by pst below, I tried to use the -whyareyoukeeping argument to determine the code path that proguard uses to determine a class is used. It does not change the output of dozens of warnings.

我也试图利用对 -outjars 文件过滤器由PST的建议。这也造成了不变化的算法仍然假定类将被加载和过滤器是拿来主义类后未正确决定只适用。

I also attempted to use a file filter on -outjars as suggested by pst. This also resulted in no change as the algorithm still assumes the class will be loaded and the filter is only applied after the "used" classes are determined incorrectly.

需要明确的是:警告是从第三方库的类,我们包括我们的Andr​​oid项目中来。我们不执行任何code,将加载这些类,如果发现proguard的地方不承担这些类加载code路径,我想明确地说,它的使用这些类。

To be clear: the warnings are coming from classes in 3rd party libraries that we are including in our Android project. We don't execute any code that will load these classes, and if proguard finds a code path where it does assume these classes are loaded, I would like to explicitly say that it does not use those classes.

推荐答案

要在outjars指定过滤器的另一种可能是在injars指定过滤器:

An alternative to specifying a filter on the outjars could be to specify a filter on the injars:

-injars in.jar(!unwanted/package/**)

这样,您将不必拖动受此包引用的任何类,因为过滤处理之前发生的事情。

This way, you won't unnecessarily drag in any classes that are referenced by this package, since the filtering is happening before any processing.

的ProGuard现在警告缺少类,所以你必须指定它的确定:

ProGuard will now warn about the missing classes, so you have to specify that it's ok:

-dontwarn unwanted.package.**

您应该小心使用这些选项,因为SUP pressing警告并不一定使问题消失。由于PST写道,你会如果你过滤掉实际所需的类获得NoClassDefFoundsErrors。

You should be careful with these options, since suppressing warnings does not necessarily make the problems go away. As pst wrote, you'll get NoClassDefFoundsErrors if you filter out classes that are actually required.

这篇关于我怎么能告诉ProGuard假设一个包没有使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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