2012-03-16 103 views
1

基本上我和这个人一样:How can I tell proguard to assume a package is not used?但我不能添加任何评论。Android上的Proguard和Netty

我不断收到警告这样的:

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中的几个特定的​​类?

+1

我现在使用netty 4,并发现上面不能在netty 4上工作,有人可以进一步帮助吗?非常感谢。 – xeoshow 2013-10-19 11:59:58

回答

1

使用它修复了一些问题ProGuard的整合(相比于ADT 16.00)最新的ADT(18.0),我是能够成功地运行我有以下附加的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%准确的,这绝对不是必须调整的解决方案,但至少它是有效的。如果您认为可以改善这一点,请随意编辑。