React-native: [Android] Regression with animated gifs in react native 0.43 - hard crash

Created on 6 Apr 2017  路  14Comments  路  Source: facebook/react-native

Description

After the upgrade to react native 0.43 from 0.42 our app crashes hard on the display of animated gifs.

Reproduction Steps and Sample Code

In http://facebook.github.io/react-native/releases/0.43/docs/image.html#gif-and-webp-support-on-android you describe how to use animated gifs with react native. Basically it's adding one line to android/app/build.gradle:

compile 'com.facebook.fresco:animated-gif:0.11.0'

and then just using the Image tag.

As a repro we did that on top of hello world sample:

For repro:

1) Clone the project
2) Check out a branch
3) run npm install
4) open android emulator
5) run react-native run-android

Additional Information

  • React Native version: 0.43.1 and 0.43
  • Platform: Android
  • Development Operating System: Windows 10
  • Dev tools: Command line
Locked

Most helpful comment

fixed by updating dependencies from 0.11.0 to 0.14.1

compile 'com.facebook.fresco:animated-base-support:0.14.1'
compile 'com.facebook.fresco:animated-gif:0.14.1'

maybe the doc is outdated.

All 14 comments

We're seeing this as well. I've attached the stack trace below. I tried blindly updating fresco to 1.2.0 on the off chance that might fix it, but no beans

04-07 09:36:57.413 12727 12887 E AndroidRuntime: java.lang.NoSuchFieldError: No field forceOldAnimationCode of type Z in class Lcom/facebook/imagepipeline/common/ImageDecodeOptions; or its superclasses (declaration of 'com.facebook.imagepipeline.common.ImageDecodeOptions' appears in /data/app/com.loclydiscover-1/base.apk)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.animated.factory.AnimatedImageFactoryImpl.decodeGif(AnimatedImageFactoryImpl.java:84)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decodeGif(DefaultImageDecoder.java:142)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.decoder.DefaultImageDecoder$1.decode(DefaultImageDecoder.java:65)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decode(DefaultImageDecoder.java:123)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.doDecode(DecodeProducer.java:239)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.access$200(DecodeProducer.java:111)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder$1.run(DecodeProducer.java:144)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.producers.JobScheduler.doJob(JobScheduler.java:207)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.producers.JobScheduler.access$000(JobScheduler.java:27)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.producers.JobScheduler$1.run(JobScheduler.java:78)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:43)
04-07 09:36:57.413 12727 12887 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:761)
04-07 09:36:57.427   919 15381 W ActivityManager:   Force finishing activity com.loclydiscover/.MainActivity

just to make this clear: the app crashes completely. It's really serious.

Thirded. Hard crash on 0.43.

fixed by updating dependencies from 0.11.0 to 0.14.1

compile 'com.facebook.fresco:animated-base-support:0.14.1'
compile 'com.facebook.fresco:animated-gif:0.14.1'

maybe the doc is outdated.

I can confirm that fresco 0.14.1 works indeed. Weird thing is that v 1.2 doesn't.

PR for docs: https://github.com/facebook/react-native/pull/13419

@AndrewJack proposed to use 1.0.1 - which seems to work as well.

build.gradle => android => buildToolsVersion "25.0.0"can fix it.

Upgrading to fresco 1.0.1 fixed for us. Thanks everyone!

Tried to use the recommended (02.09.2017) compile 'com.facebook.fresco:animated-base-support:1.3.0' with RN 0.45 and it crashed, but tested it succesfully with the newer release RN 0.48. Downgraded my app in RN to fresco 1.0.1 as mentioned above and gif works in RN 0.45 .

Maybe this could be mentioned somewhere in a more official place?

I am using RN 0.50.3
I have tried com.facebook.fresco:animated-gif v0.12.0, v0.14.1, v1.0.1, v1.3.0 ... but the app always hard-crashes on me as soon as a GIF is to be displayed.
Even tried changing buildToolsVersion 23.0.1 to 25.0.0 as someone else suggested, but no luck either.
I have no idea what to do!!!
My Android version is 5.1.1

The crash log I am getting is:

E/AndroidRuntime(28788): FATAL EXCEPTION: Thread-6976
E/AndroidRuntime(28788): Process: com.rn_test, PID: 28788
E/AndroidRuntime(28788): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/imagepipeline/memory/PooledByteBuffer;
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.animated.factory.AnimatedImageFactoryImpl.decodeGif(AnimatedImageFactoryImpl.java:84)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decodeGif(DefaultImageDecoder.java:145)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.decoder.DefaultImageDecoder$1.decode(DefaultImageDecoder.java:65)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decode(DefaultImageDecoder.java:126)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.doDecode(DecodeProducer.java:240)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.access$200(DecodeProducer.java:112)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder$1.run(DecodeProducer.java:145)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.producers.JobScheduler.doJob(JobScheduler.java:207)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.producers.JobScheduler.access$000(JobScheduler.java:27)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.producers.JobScheduler$1.run(JobScheduler.java:78)
E/AndroidRuntime(28788):        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(28788):        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(28788):        at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:43)
E/AndroidRuntime(28788):        at java.lang.Thread.run(Thread.java:818)
E/AndroidRuntime(28788): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.imagepipeline.memory.PooledByteBuffer" on path: DexPathList[[zip file "/data/app/com.rn_test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.rn_test-1/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime(28788):        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(28788):        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(28788):        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(28788):        ... 14 more
E/AndroidRuntime(28788):        Suppressed: java.lang.ClassNotFoundException: com.facebook.imagepipeline.memory.PooledByteBuffer
E/AndroidRuntime(28788):                at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(28788):                at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(28788):                at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(28788):                at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(28788):                ... 15 more
E/AndroidRuntime(28788):        Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

UPDATE: If I add:

compile 'com.facebook.fresco:imagepipeline-okhttp3:1.3.0'

... to the dependencies block of android/app/build.gradle, then animated GIFs work fine and I do not get the crash.
But the documentation on https://facebook.github.io/react-native/docs/image.html does not say that we must explicitly add this dependency. In my case I have to since otherwise my app crashes.
Is this normal?

I tried every combination, the following setup is the only working one:
react-native: 0.53.0
buildToolsVersion "27.0.2"
classpath 'com.android.tools.build:gradle:3.0.1'

compile 'com.facebook.fresco:animated-base-support:1.3.0'
compile 'com.facebook.fresco:animated-gif:1.3.0'

this way:
react-native: 0.53.3
buildToolsVersion "25.0.2"
targetSdkVersion 25
classpath 'com.android.tools.build:gradle:2.3.2'

compile 'com.facebook.fresco:animated-gif:1.3.0'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

despairblue picture despairblue  路  3Comments

josev55 picture josev55  路  3Comments

anchetaWern picture anchetaWern  路  3Comments

phongyewtong picture phongyewtong  路  3Comments

ghost picture ghost  路  3Comments