Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.dylanvann.fastimage.FastImageSource.isResource()' on a null object reference #952

Open
brandonkhy14 opened this issue Dec 14, 2022 · 9 comments
Labels

Comments

@brandonkhy14
Copy link

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
@thegdznet
Copy link

Hi!

Same problem for me.

Juste changed if (imageSource.isResource()) with if ((imageSource != null) && imageSource.isResource()) on line 111 of FastImageViewConverter.java.

@justo-admin
Copy link

@thegdznet Thanks that works !!

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

@mjooms
Copy link

mjooms commented Jan 12, 2023

Same issue here using a resource on defaultSource on prod build on Android. When source is null, I get the error.

@hizbullaharif
Copy link

same issue here?

@luluanacarla
Copy link

Any news here? I'm facing the same issue.

@vksgautam1986
Copy link

same issue

@antoinecaputo
Copy link

null object makes app crash #973 is still open :/

@antoinecaputo
Copy link

antoinecaputo commented Jun 17, 2023

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.

@thegdznet
Copy link

Thanx. Will check in ou code base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8 participants