question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference

See original GitHub issue

Using “react-native-image-picker”: “^0.18.3” I try to select an image from the device library, when selecting an image - the app crashes. This only happens on the device and not in the simulator. Here is the error:

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2, result=-1, data=Intent { dat=content: flg=0x1 }} to activity {com.myapp/com.myapp.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3881)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3931)
       at android.app.ActivityThread.access$1300(ActivityThread.java:144)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1408)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:155)
       at android.app.ActivityThread.main(ActivityThread.java:5696)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
       at com.imagepicker.ImagePickerModule.getResizedImage(ImagePickerModule.java:504)
       at com.imagepicker.ImagePickerModule.onActivityResult(ImagePickerModule.java:388)
       at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:173)
       at com.facebook.react.ReactInstanceManagerImpl.onActivityResult(ReactInstanceManagerImpl.java:526)
       at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:180)
       at com.myapp.MainActivity.onActivityResult(MainActivity.java:105)
       at android.app.Activity.dispatchActivityResult(Activity.java:6160)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:3877)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3931)
       at android.app.ActivityThread.access$1300(ActivityThread.java:144)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1408)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:155)
       at android.app.ActivityThread.main(ActivityThread.java:5696)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:29 (17 by maintainers)

github_iconTop GitHub Comments

3reactions
CodeTitaniancommented, Apr 6, 2016

Another test with “react-native-image-picker”: “^0.18.6” gives me the same error…

1reaction
dhrrgncommented, Apr 8, 2016

@yfuks Can confirm this has fixed the issue for us. Thanks for the quick turn-around on this. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attempt to invoke virtual method 'int android.graphics.Bitmap ...
The problem you are facing is that you are trying to getWidth() on your unscaledBitmap in the createScaledBitmap function.
Read more >
Attempt to invoke virtual method 'int android.graphics.Bitmap ...
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference #49. Open.
Read more >
int android.graphics.Bitmap.getWidth() - Issue Tracker
Error: java.lang.NullPointerException:Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
Read more >
Attempt to invoke virtual method ''int android.graphics.Bitmap ...
NullPointerException: Attempt to invoke virtual method ''int android.graphics.Bitmap.getWidth()'' on a null object reference at android.graphics.Bitmap.
Read more >
Attempt to invoke virtual method 'int android.graphics.Bitmap ...
getWidth ()' on a null object reference. androidandroid-activityandroid-bitmapnullpointerexception. I have BitmapScalingHelper.java:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found