2013-09-22 32 views
0

我已經使用netty編寫了一個服務器和一個本地代理。該項目在我的電腦上運行良好,但是當我改變了一下使它成爲一個android應用程序,它就無法工作。在Android上添加spdy編解碼器後使用netty連接失敗

我嘗試了很多次,發現插入下面的代碼後,事情就出錯了。

pipeline.addLast("spdyEncoder", new SpdyFrameEncoder(3)); 
pipeline.addLast("spdyDecoder", new SpdyFrameDecoder(3)); 

我比較了添加或不SPDY編解碼器之間的日誌,所不同的是

找不到類‘com.jcraft.jzlib.Deflater’,從方法io.netty.handler引用.codec.spdy.SpdyHeaderBlockJZlibEncoder。「,所以我想問題是與jzlib deflater,但我真的不知道如何解決它。任何人都可以幫助我,事先要多謝。

這裏是logcat的:

09-22 03:35:15.761: D/Multiplex(863): initInstance 
09-22 03:35:15.761: D/MultiplexChannelConnMgr(863): constructor 
09-22 03:35:15.771: I/dalvikvm(863): Could not find method org.slf4j.LoggerFactory.getILoggerFactory, referenced from method io.netty.util.internal.logging.Slf4JLoggerFactory.<init> 
09-22 03:35:15.771: W/dalvikvm(863): VFY: unable to resolve static method 28005: Lorg/slf4j/LoggerFactory;.getILoggerFactory()Lorg/slf4j/ILoggerFactory; 
09-22 03:35:15.771: D/dalvikvm(863): VFY: replacing opcode 0x71 at 0x0026 
09-22 03:35:15.781: I/dalvikvm(863): Could not find method org.slf4j.LoggerFactory.getLogger, referenced from method io.netty.util.internal.logging.Slf4JLoggerFactory.newInstance 
09-22 03:35:15.781: W/dalvikvm(863): VFY: unable to resolve static method 28006: Lorg/slf4j/LoggerFactory;.getLogger (Ljava/lang/String;)Lorg/slf4j/Logger; 
09-22 03:35:15.794: D/dalvikvm(863): VFY: replacing opcode 0x71 at 0x0002 
09-22 03:35:15.862: W/System.err(863): log4j:WARN No appenders could be found for logger (io.netty.util.internal.logging.InternalLoggerFactory). 
09-22 03:35:15.871: W/System.err(863): log4j:WARN Please initialize the log4j system properly. 
09-22 03:35:15.871: W/System.err(863): log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 
09-22 03:35:16.110: D/dalvikvm(863): GC_CONCURRENT freed 121K, 9% free 2660K/2904K, paused 70ms+38ms, total 213ms 
09-22 03:35:16.180: E/dalvikvm(863): Could not find class 'javassist.ClassPool', referenced from method io.netty.util.internal.JavassistTypeParameterMatcherGenerator.<clinit> 
09-22 03:35:16.180: W/dalvikvm(863): VFY: unable to resolve new-instance 2027 (Ljavassist/ClassPool;) in Lio/netty/util/internal/JavassistTypeParameterMatcherGenerator; 
09-22 03:35:16.180: D/dalvikvm(863): VFY: replacing opcode 0x22 at 0x0008 
09-22 03:35:16.180: I/dalvikvm(863): Could not find method javassist.ClassPool.getAndRename, referenced from method io.netty.util.internal.JavassistTypeParameterMatcherGenerator.generate 
09-22 03:35:16.190: W/dalvikvm(863): VFY: unable to resolve virtual method 16552: Ljavassist/ClassPool;.getAndRename (Ljava/lang/String;Ljava/lang/String;)Ljavassist/CtClass; 
09-22 03:35:16.190: D/dalvikvm(863): VFY: replacing opcode 0x6e at 0x0032 
09-22 03:35:16.190: I/dalvikvm(863): Could not find method javassist.ClassPool.appendClassPath, referenced from method io.netty.util.internal.JavassistTypeParameterMatcherGenerator.appendClassPath 
09-22 03:35:16.190: W/dalvikvm(863): VFY: unable to resolve virtual method 16550: Ljavassist/ClassPool;.appendClassPath (Ljava/lang/String;)Ljavassist/ClassPath; 
09-22 03:35:16.190: D/dalvikvm(863): VFY: replacing opcode 0x6e at 0x0002 
09-22 03:35:16.190: W/dalvikvm(863): VFY: unable to find class referenced in signature (Ljavassist/ClassPath;) 
09-22 03:35:16.190: I/dalvikvm(863): Could not find method javassist.ClassPool.appendClassPath, referenced from method io.netty.util.internal.JavassistTypeParameterMatcherGenerator.appendClassPath 
09-22 03:35:16.190: W/dalvikvm(863): VFY: unable to resolve virtual method 16551: Ljavassist/ClassPool;.appendClassPath (Ljavassist/ClassPath;)Ljavassist/ClassPath; 
09-22 03:35:16.190: D/dalvikvm(863): VFY: replacing opcode 0x6e at 0x0002 
09-22 03:35:16.190: D/dalvikvm(863): DexOpt: unable to opt direct call 0x40a5 at 0x0b in Lio/netty/util/internal/JavassistTypeParameterMatcherGenerator;.<clinit> 
09-22 03:35:16.200: D/dalvikvm(863): DexOpt: unable to opt direct call 0x40a4 at 0x16 in Lio/netty/util/internal/JavassistTypeParameterMatcherGenerator;.<clinit> 
09-22 03:35:16.200: W/dalvikvm(863): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lio/netty/util/internal/JavassistTypeParameterMatcherGenerator; 
09-22 03:35:16.260: D/MultiplexChannelConnMgr(863): Before connect to 10.108.112.239:9001 
09-22 03:35:16.330: E/dalvikvm(863): Could not find class 'com.jcraft.jzlib.Deflater', referenced from method io.netty.handler.codec.spdy.SpdyHeaderBlockJZlibEncoder.<init> 
09-22 03:35:16.330: W/dalvikvm(863): VFY: unable to resolve new-instance 574 (Lcom/jcraft/jzlib/Deflater;) in Lio/netty/handler/codec/spdy/SpdyHeaderBlockJZlibEncoder; 
09-22 03:35:16.330: D/dalvikvm(863): VFY: replacing opcode 0x22 at 0x0005 
09-22 03:35:16.340: W/dalvikvm(863): VFY: unable to resolve instance field 1051 
09-22 03:35:16.340: D/dalvikvm(863): VFY: replacing opcode 0x54 at 0x0003 
09-22 03:35:16.340: W/dalvikvm(863): VFY: unable to resolve instance field 1051 
09-22 03:35:16.340: D/dalvikvm(863): VFY: replacing opcode 0x5b at 0x0049 
09-22 03:35:16.350: W/dalvikvm(863): VFY: unable to resolve instance field 1051 
09-22 03:35:16.350: D/dalvikvm(863): VFY: replacing opcode 0x5b at 0x000b 
09-22 03:35:16.361: I/dalvikvm(863): Could not find method com.jcraft.jzlib.Deflater.deflateEnd, referenced from method io.netty.handler.codec.spdy.SpdyHeaderBlockJZlibEncoder.end 
09-22 03:35:16.361: W/dalvikvm(863): VFY: unable to resolve virtual method 4173: Lcom/jcraft/jzlib/Deflater;.deflateEnd()I 
09-22 03:35:16.361: D/dalvikvm(863): VFY: replacing opcode 0x6e at 0x000b 
09-22 03:35:16.361: D/dalvikvm(863): DexOpt: unable to opt direct call 0x104b at 0x07 in Lio/netty/handler/codec/spdy/SpdyHeaderBlockJZlibEncoder;.<init> 
09-22 03:35:16.381: D/MultiplexChannelConnMgr(863): Catch error: null 
**09-22 03:35:16.381: W/System.err(863): java.nio.channels.ClosedChannelException** 

回答

0

您需要com.jcraft.jzlib添加到類路徑。這是通過添加jzlib jar完成的。

http://www.jcraft.com/jzlib/

+0

非常感謝。我很高興能解決這個問題。事實上,這個問題相當明顯,但沒有你的幫助,我仍然無法繼續前進。我需要學習如何解決問題。再次感謝。 – user2552042