Netty 3.4.1.Final does not work on Android

2019-07-07 07:48发布

Yesterday I tried to upgrade from 3.3.2.Final-SNAPSHOT to latest release. However, it fails on Android due to the following error:

  • /AndroidRuntime( 720): FATAL EXCEPTION: main E/AndroidRuntime( 720): java.lang.NoClassDefFoundError: java.util.concurrent.LinkedTransferQueue E/AndroidRuntime( 720): at org.jboss.netty.util.internal.QueueFactory.createQueue(QueueFactory.java:48)

It turns out that on Android (this is 2.3), DetecationUtil.javaVersion() returns 7 since the Deflater class contains the field SYNC_FLUSH. Below are all fields Deflater.getDeclaredFields().

04-25 08:08:51.305: I/System.out(25674): [public static final int java.util.zip.Deflater.BEST_COMPRESSION, public static final int java.util.zip.Deflater.BEST_SPEED, public static final int java.util.zip.Deflater.DEFAULT_COMPRESSION, public static final int java.util.zip.Deflater.DEFAULT_STRATEGY, public static final int java.util.zip.Deflater.DEFLATED, public static final int java.util.zip.Deflater.FILTERED, private static final int java.util.zip.Deflater.FINISH, public static final int java.util.zip.Deflater.FULL_FLUSH, public static final int java.util.zip.Deflater.HUFFMAN_ONLY, public static final int java.util.zip.Deflater.NO_COMPRESSION, public static final int java.util.zip.Deflater.NO_FLUSH, private static final [B java.util.zip.Deflater.STUB_INPUT_BUFFER, public static final int java.util.zip.Deflater.SYNC_FLUSH, private [B java.util.zip.Deflater.inputBuffer, private boolean java.util.zip.Deflater.finished, private long java.util.zip.Deflater.streamHandle, private int java.util.zip.Deflater.inLength, private int java.util.zip.Deflater.inRead, private int java.util.zip.Deflater.compressLevel, private int java.util.zip.Deflater.strategy, private int java.util.zip.Deflater.flushParm]

Is there any other way that this could be solved so it can work on Android platform? I have not looked into that (yet...). IF android is a platform that should be supported maybe we could also check for android specific classes?

Something like this could be added to int javaVersion0() in DetectionUtil:

try {
        Class.forName("android.app.Application");
        return 5;
    } catch (ClassNotFoundException e) {
        //Ignore
    }

Kind regards /Johan Rask

标签: netty
1条回答
Emotional °昔
2楼-- · 2019-07-07 08:02

Please open a issue in the issue tracker of netty. I will make sure we handle it in the next release which should be out next week.

See issue tracker is here [1].

[1] https://github.com/netty/netty/issues

查看更多
登录 后发表回答