Expo Client App Crashes on Camera.takePictureAsync()

I have just upgraded to expo SDK 38 from version 36, and now when running in the android emulator, the Expo Client app crashes whenever I try to take a photo with expo Camera using takePictureAsync()

ADB log shows this seems to be caused by a null pointer. It’s frustrating because I was able to successfully test with version 36. Does anyone know anything more or have a workaround?

08-06 18:03:13.113 31160 31417 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #11
08-06 18:03:13.113 31160 31417 E AndroidRuntime: Process: host.exp.exponent, PID: 31160
08-06 18:03:13.113 31160 31417 E AndroidRuntime: java.lang.RuntimeException: An error occurred while executing doInBackground()
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at android.os.AsyncTask$4.done(AsyncTask.java:415)
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:923)
08-06 18:03:13.113 31160 31417 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to get length of null array
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:106)
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at abi38_0_0.expo.modules.camera.tasks.ResolveTakenPictureAsyncTask.doInBackground(ResolveTakenPictureAsyncTask.java:7)
08-06 18:03:13.113 31160 31417 E AndroidRuntime:        at abi38_0_0.expo.modules.camera.tasks.ResolveTakenPictureAsyncTask.d
08-06 18:03:13.120  2296 31424 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
3 Likes

I have the same issue, urgently need help on this as I can’t seem to figure out what’s going wrong and am getting 0 error logs

3 Likes

I have the same error on android since I upgraded to SDK 39 (from 35).
The android emulator crashes all the time when calling takePictureAsync (api 23, 25, 27 and 29). On the live app (standalone app with managed workflow), the app crashes at the same step (I don’t have logs of the crash) for some users, and it works fine for others. I don’t know why.

This issue is impacting our production users, so it would be nice to have a fix or work around for that.

Do you have any information about that? Is there a GitHub issue we can follow?
Thanks a lot for your help, Expo rocks!

2 Likes

Same error here.

1 Like

Hi guys, any update on this issue ? Same as @denis.barriere, for me it crashes on some android devices and not on others, works on iOS, this is pretty urgent and serious issue and any help would be appreciated

1 Like

I am also running into this issue after expo upgrading from SDK 36 to SDK 38. Crashes on some Androids but not on others as well. I put a message into the Expo slack channel last week but didn’t get a response

Just following up over here for anybody that might run into a similar issue to mine. It ended up being a matter of explicitly using the Camera 2 API, in particular on Google Pixel phones though I’m sure this is necessary on other devices. So dynamically setting the prop useCamera2Api={true} when necessary should fix the issue. Docs for useCamera2Api for reference