penfeizhou / APNG4Android

Android animation support for APNG & Animated WebP & Gif & Animated AVIF, High performance
Apache License 2.0
570 stars 75 forks source link

java.lang.UnsatisfiedLinkError crash #142

Closed connyduck closed 2 years ago

connyduck commented 2 years ago

Since upgrading to v2.18.0, my R8 minified production app crashes with java.lang.UnsatisfiedLinkError when loading a gif. It does not happen in a debug build.

Full stacktrace ``` 2022-03-21 19:05:01.393 4186-4592/? E/lace.tusky.tes: ----- class 'Lcom/github/penfeizhou/animation/gif/decode/GifFrame;' cl=0x14bcb408 ----- objectSize=252 (120 from super) access=0x0008.0001 super='java.lang.Class' (cl=0x14bcb408) vtable (3 entries, 1 in super): 0: android.graphics.Bitmap com.github.penfeizhou.animation.gif.decode.GifFrame.a(android.graphics.Canvas, android.graphics.Paint, int, android.graphics.Bitmap, l4.a) 1: android.graphics.Bitmap com.github.penfeizhou.animation.gif.decode.GifFrame.b(android.graphics.Canvas, android.graphics.Paint, int, android.graphics.Bitmap, j4.b) 2: void com.github.penfeizhou.animation.gif.decode.GifFrame.c(int[], int) direct methods (3 entries): 0: void com.github.penfeizhou.animation.gif.decode.GifFrame.() 1: void com.github.penfeizhou.animation.gif.decode.GifFrame.(j4.a, i4.c, i4.i, i4.j) 2: void com.github.penfeizhou.animation.gif.decode.GifFrame.uncompressLZW(j4.a, int[], int, int[], int, int, int, boolean, byte[]) static fields (1 entries): 0: java.lang.ThreadLocal com.github.penfeizhou.animation.gif.decode.GifFrame.m instance fields (6 entries): 0: int com.github.penfeizhou.animation.gif.decode.GifFrame.g 1: int com.github.penfeizhou.animation.gif.decode.GifFrame.h 2: i4.c com.github.penfeizhou.animation.gif.decode.GifFrame.i 3: int com.github.penfeizhou.animation.gif.decode.GifFrame.j 4: int com.github.penfeizhou.animation.gif.decode.GifFrame.k 5: boolean com.github.penfeizhou.animation.gif.decode.GifFrame.l 2022-03-21 19:05:01.393 4186-4592/? E/lace.tusky.tes: Failed to register native method com.github.penfeizhou.animation.gif.decode.GifFrame.uncompressLZW(Lcom/github/penfeizhou/animation/gif/io/GifReader;[II[IIIIZ[B)V in /data/app/~~gIva4amPJv-HOnwdQiwyRA==/com.keylesspalace.tusky.test-YBFLschFUZrItAPr8PyhbQ==/base.apk 2022-03-21 19:05:01.393 4186-4592/? E/AndroidRuntime: FATAL EXCEPTION: FrameDecoderExecutor-0 Process: com.keylesspalace.tusky.test, PID: 4186 java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/~~gIva4amPJv-HOnwdQiwyRA==/com.keylesspalace.tusky.test-YBFLschFUZrItAPr8PyhbQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a/libanimation-decoder-gif.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at com.github.penfeizhou.animation.gif.decode.GifFrame.(SourceFile:1) at i4.g.m(SourceFile:34) at androidx.appcompat.widget.j.run(SourceFile:32) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67) ```

I believe this is due to this change and there is -keep class com.github.penfeizhou.animation.gif.io.GifReader missing in the consumer proguard rules.

penfeizhou commented 2 years ago

This may change some default proguard behavior. I've fixed this ad updated to v2.20.0. Please try this version.Thanks for this feedback.

connyduck commented 2 years ago

Can confirm this fixed it, thanks!