2012-03-16 58 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%準確的,這絕對不是必須調整的解決方案,但至少它是有效的。如果您認爲可以改善這一點,請隨意編輯。