react-native-fast-image
react-native-fast-image copied to clipboard
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.dylanvann.fastimage.FastImageSource.isResource()' on a null object reference
Describe the bug
The app crashed in release mode for android when run react-native-fast-image with defaultSouce, working well in debug mode.
Remark: iOS working well.
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.dylanvann.fastimage.FastImageSource.isResource()' on a null object reference at com.dylanvann.fastimage.FastImageViewConverter.getOptions(FastImageViewConverter.java:111) at com.dylanvann.fastimage.FastImageViewWithUrl.onAfterUpdate(FastImageViewWithUrl.java:143) at com.dylanvann.fastimage.FastImageViewManager.onAfterUpdateTransaction(FastImageViewManager.java:181) at com.dylanvann.fastimage.FastImageViewManager.onAfterUpdateTransaction(FastImageViewManager.java:33) at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:88) at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:188) at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:115) at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:281) at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:194) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:1110) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1081) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1010) at android.view.Choreographer.doCallbacks(Choreographer.java:823) at android.view.Choreographer.doFrame(Choreographer.java:755) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:998) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6846) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:883)
To Reproduce
<FastImage defaultSource={require('./default-images/image-1.jpg')} source={{uri: 'https://pbs.twimg.com/profile_images/1455185376876826625/s1AjSxph_400x400.jpg'}} resizeMode={'cover'} style={{ height: 220, width: PRODUCT_CARD_WIDTH, borderTopLeftRadius: 10, borderTopRightRadius: 10, }} />
Expected behavior Expected to show default picture from defaultSource if source image is unavailable.
Screenshots App crashed directly when screen loaded.
Dependency versions
- React Native version: 0.70.2
- React version: 18.1.0
- React Native Fast Image version: 8.6.1
Hi!
Same problem for me.
Juste changed if (imageSource.isResource())
with if ((imageSource != null) && imageSource.isResource())
on line 111 of FastImageViewConverter.java.
@thegdznet Thanks that works !!
Hi!
Same problem for me.
Juste changed
if (imageSource.isResource())
withif ((imageSource != null) && imageSource.isResource())
on line 111 of FastImageViewConverter.java.
@thegdznet Thanks!! That works
Same issue here using a resource on defaultSource on prod build on Android. When source is null, I get the error.
same issue here?
Any news here? I'm facing the same issue.
same issue
null object makes app crash #973 is still open :/
To fix it in your code, make sure that you always pass to FastImage at least
source={{ uri=null }}
It will crash when the source property is null.
Thanx. Will check in ou code base.