不要优化特定的类路径使用ProGuard [英] Do not optimize a specific class path with Proguard

查看:641
本文介绍了不要优化特定的类路径使用ProGuard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试实施亚马逊应用程序内购买在我的Andr​​oid应用程序。亚马逊<一href="https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs/$c$c-obfuscation#Setting%20Up%20$c$c%20Obfuscation%20for%20your%20Project"相对=nofollow>文档需要指定-dontoptimize在ProGuard的规则。

I try to implement Amazon In App Purchase in my android application. Amazons documentation requires to specify -dontoptimize in the proguard rules.

该-dontoptimize规则是,将关闭所有的优化,但我确实希望优化其他code全局选项。所以我的问题是如何指定ProGuard的规则不仅没有优化亚马逊IAP code?

The -dontoptimize rule is a global option which will turn off all optimization, but I do want to optimize the other code. So my question is how to specify the proguard rules to only not optimize the Amazon iap code?

看来,-keep规则是不够的。这个问题是与此相关的 SO回答 但我要求的方式来保持优化的的code中的休息,而让 亚马逊IAP工作。

It seems that the -keep rule is not enough. This question is related to this SO answer but I am asking for a way to keep the optimizations for the rest of the code while allowing Amazon IAP to work.

推荐答案

您可以限制不过滤优化: -optimizations!code /配置/变量

You can limit the "do not" optimize by filter: -optimizations !code/allocation/variable

为什么亚马逊IAP需要理由的 -dontoptimize 是一个有点棘手。

The reason of why Amazon IAP requires -dontoptimize is a little bit tricky.

首先,<一个href="https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs/$c$c-obfuscation#Setting%20Up%20$c$c%20Obfuscation%20for%20your%20Project"相对=nofollow>亚马逊IAP文档要求 -dontwarn com.amazon。**

如果你删除它,你会看到ProGuard的抱怨找不到参考了一些类包: com.amazon.android的 com.amazon .venezia。

If you remove it, you will see the proguard complain that it can not find reference to some class in the package: com.amazon.android. and com.amazon.venezia..

因此​​,它证明了亚马逊的在应用程序 - 采购 - 1.0.7.jar 的具有外部依赖的jar。

So it proves that amazon in-app-purchasing-1.0.7.jar has an external dependent jar.

现在这里是一个问题。当ProGuard的执行优化任务。它需要知道为了做适当的优化所有的依赖库(例如,删除从未使用过的方法,无用参数等)。

Now here is a problem. When proguard executes the optimization task. It needs to know all the dependent libraries in order to do proper optimization (e.g. remove never used method, useless parameters etc.).

而在这种情况下的ProGuard不知道的外部依赖亚马逊的jar 的,它会做一些错误的优化了的在应用程序 - 采购 - 1.0.7.jar 的。

While in this case proguard does not know the external dependent amazon jar, it will do some wrong optimizations for the in-app-purchasing-1.0.7.jar.

这也是为什么亚马逊需要的 -dontoptimize

This is also why Amazon requires -dontoptimize.

这听起来ProGuard的一个错误。但不幸的是,即使你更新到最新的ProGuard(5.0)这个问题的存在。

This sounds a bug of proguard. But unfortunately this issue exists even you update to the latest proguard (5.0).

这篇关于不要优化特定的类路径使用ProGuard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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