【问题标题】:Proguard and Netty on AndroidAndroid 上的 Proguard 和 Netty
【发布时间】:2012-03-16 00:16:08
【问题描述】:

基本上我正在尝试和这个人一样:How can I tell proguard to assume a package is not used?,但我无法添加任何 cmets。

我不断收到这样的警告:

Warning: org.jboss.netty.logging.Slf4JLogger: can't find referenced class org.slf4j.Logger

基本上,org.jboss.netty.logging.Slf4JLogger 引用了第三方库类org.slf4j.Logger,这不是我项目的一部分。 org.jboss.netty.logging.Slf4JLogger 也没有使用。

所以我尝试告诉 proguard 不要加载/使用 Eric Lafortune 建议的 org.jboss.netty.logging.Slf4JLogger,但这样做总是失败。 我添加了-injars libs/netty-3.3.1.Final.jar(!**Slf4JLogger)-injars libs/netty-3.3.1.Final.jar(!**Slf4JLogger.class),但这似乎没有任何作用。甚至 -injars libs/netty-3.3.1.Final.jar("!whatever is in here") 产生相同的结果,所以我假设这个选项没有做任何事情......

如何告诉 Proguard 不考虑 netty.jar 中的几个特定类?

【问题讨论】:

  • 我现在正在使用netty 4,发现上面不能在netty 4上工作,有人可以帮忙吗?非常感谢。

标签: android proguard netty


【解决方案1】:

使用修复了 ProGuard 集成的一些问题的最新 ADT (18.0)(与 ADT 16.00 相比),我能够通过以下额外的 ProGuard 设置成功运行基于 Netty 的应用程序:

 # Get rid of warnings about unreachable but unused classes referred to by Netty
-dontwarn org.jboss.netty.**

# Needed by commons logging
-keep class org.apache.commons.logging.* {*;}

#Some Factory that seemed to be pruned
-keep class java.util.concurrent.atomic.AtomicReferenceFieldUpdater {*;}
-keep class java.util.concurrent.atomic.AtomicReferenceFieldUpdaterImpl{*;}

#Some important internal fields that where removed     
-keep class org.jboss.netty.channel.DefaultChannelPipeline{volatile <fields>;}

#A Factory which has a static factory implementation selector which is pruned
-keep class org.jboss.netty.util.internal.QueueFactory{static <fields>;}

#Some fields whose names need to be maintained because they are accessed using inflection
-keepclassmembernames class org.jboss.netty.util.internal.**{*;}

我关于为什么需要特定线路的结论可能不是 100% 精确,这绝对不是必须调整的解决方案,但至少它有效。如果您认为可以改进,请随时编辑。

【讨论】:

    猜你喜欢
    • 2015-01-20
    • 2011-09-25
    • 1970-01-01
    • 2011-09-19
    • 2011-12-03
    • 2014-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多