Androidstudio提示更新gradle依赖,更新之后加载GIF就出现崩溃了,报错:
java.lang.NoSuchFieldError: No field forceOldAnimationCode of type Z in class Lcom/facebook/imagepipeline/common/a; or its superclasses (declaration of 'com.facebook.imagepipeline.common.a' appears in /data/app/com.huitong.privateboard-1/base.apk)
at com.facebook.imagepipeline.animated.factory.g.a(AnimatedImageFactoryImpl.java:84)
at com.facebook.imagepipeline.decoder.a.a(DefaultImageDecoder.java:145)
at com.facebook.imagepipeline.decoder.a$1.a(DefaultImageDecoder.java:65)
at com.facebook.imagepipeline.decoder.a.a(DefaultImageDecoder.java:126)
at com.facebook.imagepipeline.i.l$c.c(DecodeProducer.java:240)
at com.facebook.imagepipeline.i.l$c.a(DecodeProducer.java:112)
at com.facebook.imagepipeline.i.l$c$1.a(DecodeProducer.java:145)
at com.facebook.imagepipeline.i.u.e(JobScheduler.java:207)
at com.facebook.imagepipeline.i.u.a(JobScheduler.java:27)
at com.facebook.imagepipeline.i.u$1.run(JobScheduler.java:78)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.facebook.imagepipeline.c.k$1.run(PriorityThreadFactory.java:43)
at java.lang.Thread.run(Thread.java:761)
Google查资料后发现是fresco依赖版本不一致的原因,下面是我的依赖:
implementation 'com.facebook.fresco:fresco:1.11.0'
implementation 'com.facebook.fresco:animated-gif:0.12.0'
把GIF依赖修改为同样的版本就好了
implementation 'com.facebook.fresco:fresco:1.11.0'
implementation 'com.facebook.fresco:animated-gif:1.11.0'
至于为什么studio不提示gif依赖暂时还不清楚,还有刚开始studio提示更新的版本是1.3.0,1.11.0是我到fresco官方github找到的最新依赖,为什么studio不提示最新的1.11.0呢?