You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-09-25] [$250] Android - Attachment - App crashes after taking a photo #84018
Please re-state the problem that we are trying to solve in this issue.
On Android, taking a photo via the attachment picker (+ > Add attachment > Take photo) causes the app to crash immediately after the user taps OK to confirm the photo.
What is the root cause of that problem?
The crash originates in react-native-image-picker v7.1.2's Utils.java. After the camera returns a result, getResponseMap calls isImageType, which calls getMimeType. Inside getMimeType, when the URI scheme is content, the code calls contentResolver.getType(uri) and then immediately invokes .isBlank() on the result — but ContentResolver.getType() is documented to return null when the type is unknown, which causes a NullPointerException crash. On Android 16 (the OS version reported in the bug), this null return appears to happen consistently for the file-provider content URI used by the camera capture flow.
What changes do you think we should make in order to solve the problem?
Add a third patch file for react-native-image-picker that adds a null-guard before calling .isBlank() in getMimeType. The fix follows the same patch infrastructure already used in patches/react-native-image-picker/.
The patch file should be placed at patches/react-native-image-picker/react-native-image-picker+7.1.2+003+null-check-getMimeType.patch and a corresponding entry added to patches/react-native-image-picker/details.md. This is a one-line null-guard that matches how Android's own documentation specifies the API behaves, and it unblocks the fallback getMimeTypeForContent path that already exists for exactly this scenario.
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
On Android (Samsung Galaxy S25 FE / Android 16), the app crashes after taking a photo via Chat → + → Add attachment → Take photo → OK. This is a regression in v9.3.28-0, reproducible in both staging and production.
What is the root cause of that problem?
The crash is most likely caused by Android 16's 16KB page alignment enforcement combined with react-native-image-picker v7.1.2 never having been updated for Android 16 / SDK 36 compatibility.
The crash mechanism:
When the user taps "Take photo," the AttachmentPicker calls launchCamera (launchCamera.android.ts:12-30), which launches a camera Intent via react-native-image-picker's ImagePickerModuleImpl.java using startActivityForResult. When the system camera opens in the foreground, the OS may kill the Expensify app process to reclaim memory. After the user taps OK, Android tries to restore the Expensify process, which requires reloading all native .so libraries. If any .so file has 4KB-aligned ELF segments instead of the 16KB alignment required by Android 16, the process crashes with a native SIGBUS/SIGSEGV.
Supporting evidence:
The app targets SDK 36 (android/build.gradle:6-7: compileSdkVersion = 36, targetSdkVersion = 36) which requires 16KB page alignment on Android 16 devices
react-native-image-picker was never updated for 16KB compatibility — it still targets compileSdkVersion 33 / targetSdkVersion 33 (at node_modules/react-native-image-picker/android/build.gradle:11,29). Issue [Due for payment 2026-03-13] [Due for payment soon?] Enable 16KB memory page size on Android #63871 drove 16KB alignment updates to many libraries (VisionCamera, blob-util, expo-image, onfido, mapbox, react-native-pdf, group-ib-fp, Fresco) but react-native-image-picker was missed
Samsung Galaxy S25 FE with Android 16 is one of the first consumer devices enforcing 16KB page sizes, making this the first time the issue would surface in regression testing
Alternative consideration: If the crash is not 16KB-alignment-related, a secondary candidate is a NullPointerException in Utils.getMimeType() (Utils.java:405) where contentResolver.getType(uri) can return null and .isBlank() is called without a null check. However, for camera captures, the code uses a file:// URI which takes a different code branch, making this less likely.
What changes do you think we should make in order to solve the problem?
First: Obtain the actual crash trace (logcat/Sentry) from a Samsung Galaxy S25 FE running Android 16 to confirm whether this is a SIGBUS/SIGSEGV (alignment crash) or a Java exception
If Java NPE: Apply a null-safety fix to Utils.getMimeType() by adding a null check on the contentResolver.getType(uri) return value at Utils.java:405, either by patching the library or upgrading to a newer version that fixes this
What alternative solutions did you explore? (Optional)
Replacing react-native-image-picker entirely: The IOURequestStepScan flow already uses react-native-vision-camera directly for receipt scanning, which has been updated for 16KB alignment. The AttachmentPicker could be refactored to use VisionCamera instead, but this is a larger scope change
Adding a custom launchCamera implementation: Use the newer Activity Result API (registerForActivityResult) instead of the deprecated startActivityForResult pattern in react-native-image-picker, which may also improve compatibility with Android 16's stricter activity lifecycle handling
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
changed the title [-]Android - Attachment - App crashes after taking a photo[/-][+][$250] Android - Attachment - App crashes after taking a photo[/+]on Mar 3, 2026
Please re-state the problem that we are trying to solve in this issue.
On Android 16 (Samsung Galaxy S25 FE), the app crashes immediately after taking a photo via the attachment picker (+ > Add attachment > Take photo > OK).
What is the root cause of that problem?
The crash is a NullPointerException in react-native-image-picker's Utils. After the camera returns a result, the library calls getImageResponseMap() which calls getImageDimensions(). Inside getImageDimensions(), getOrientation() is called at line 160, which returns exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION) — this can return null when the EXIF orientation tag is absent from the captured image.
The null orientation is then passed to needToSwapDimension() at line 200, which calls orientation.equals(...) on the null value, causing the NPE crash. On Android 16, certain camera implementations no longer guarantee the EXIF orientation tag is written, making this null return consistent.
This is distinct from the getMimeType() NPE identified in MobileMage's proposal. The camera capture flow uses a file:// URI (created via Uri.fromFile() at line 211), so the content:// branch in getMimeType() where contentResolverMimeType.isBlank() can NPE is never reached during camera capture. The actual crash path is: onActivityResult → onAssetsObtained → getResponseMap → getImageResponseMap → getImageDimensions → getOrientation returns null → needToSwapDimension(null) → NPE.
Additionally, setOrientation() at line 253 has the same null-unsafe pattern: orientation.equals(...) will NPE if orientation is null.
What changes do you think we should make in order to solve the problem?
Add a patch file at patches/react-native-image-picker/react-native-image-picker+7.1.2+003+null-safe-orientation.patch that null-guards orientation in both needToSwapDimension and setOrientation:
A corresponding entry should be added to patches/react-native-image-picker/details.md.
What alternative solutions did you explore? (Optional)
MobileMage's proposal targets the getMimeType() null check on contentResolverMimeType.isBlank(). While that is a legitimate bug for the gallery/content-picker flow, it is not the crash path for camera capture — camera uses a file:// URI which takes a completely different branch in getMimeType(). That fix alone would not resolve this issue. Ideally both patches should be applied (the getMimeType null guard for gallery picks, and this orientation null guard for camera captures), but the orientation fix is the one that addresses the reported crash scenario.
Please re-state the problem that we are trying to solve in this issue.
The app crashes immediately after taking a photo via the attachment picker
What is the root cause of that problem?
When the user opens the system camera from the chat attachment flow, the main activity goes to the background. Android can recreate the activity when the user returns (e.g. due to low memory, “Don’t keep activities” in Developer Options, or normal lifecycle behavior). When the activity is recreated, the system calls onCreate(savedInstanceState) with a non-null bundle so the activity can restore its state.
In MainActivity.kt, the code calls super.onCreate(null) instead of super.onCreate(savedInstanceState).
Passing null tells the Android framework that there is no saved state, so the activity (and React Native) are treated as a fresh start. That can leave the app in an inconsistent state when the camera result is delivered (e.g. via onActivityResult). The recreated activity may try to restore or run against torn-down or mismatched UI/bridge state, which can lead to a crash instead of returning to the chat with the photo attached.
What changes do you think we should make in order to solve the problem?
Pass savedInstanceState to super.onCreate() so the activity (and React Native) restore state when the activity is recreated after returning from the camera. That keeps the app in a consistent state when the image picker result is applied and prevents the crash.
diff --git a/App/android/app/src/main/java/com/expensify/chat/MainActivity.kt b/App/android/app/src/main/java/com/expensify/chat/MainActivity.kt
index 1234567890..abcdef1234 100644
--- a/App/android/app/src/main/java/com/expensify/chat/MainActivity.kt+++ b/App/android/app/src/main/java/com/expensify/chat/MainActivity.kt@@ -37,7 +37,7 @@ class MainActivity : ReactActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
BootSplash.init(this)
- super.onCreate(null)+ super.onCreate(savedInstanceState)
if (resources.getBoolean(R.bool.portrait_only)) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
Replace super.onCreate(null) with super.onCreate(savedInstanceState) so that when the activity is recreated after taking a photo, the framework restores the activity state and the app does not crash; the user returns to the chat and the captured image can be attached correctly.
Activity
melvin-bot commentedon Mar 3, 2026
Triggered auto assignment to @dylanexpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.MobileMage commentedon Mar 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Android, taking a photo via the attachment picker (+ > Add attachment > Take photo) causes the app to crash immediately after the user taps OK to confirm the photo.
What is the root cause of that problem?
The crash originates in
react-native-image-pickerv7.1.2'sUtils.java. After the camera returns a result,getResponseMapcallsisImageType, which callsgetMimeType. InsidegetMimeType, when the URI scheme iscontent, the code callscontentResolver.getType(uri)and then immediately invokes.isBlank()on the result — butContentResolver.getType()is documented to returnnullwhen the type is unknown, which causes aNullPointerExceptioncrash. On Android 16 (the OS version reported in the bug), this null return appears to happen consistently for the file-provider content URI used by the camera capture flow.https://github.com/Expensify/App/blob/bf2ae7e4cd5d3eb36199aaaf247ce37ca205a5c3/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/Utils.java#L398-L413
What changes do you think we should make in order to solve the problem?
Add a third patch file for
react-native-image-pickerthat adds a null-guard before calling.isBlank()ingetMimeType. The fix follows the same patch infrastructure already used inpatches/react-native-image-picker/.// node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/Utils.java static String getMimeType(Uri uri, Context context) { if (uri.getScheme().equals("file")) { return MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString())); } else if (uri.getScheme().equals("content")) { ContentResolver contentResolver = context.getContentResolver(); String contentResolverMimeType = contentResolver.getType(uri); - if (contentResolverMimeType.isBlank()) { + if (contentResolverMimeType == null || contentResolverMimeType.isBlank()) { return getMimeTypeForContent(uri, context); } else { return contentResolverMimeType; } } return "Unknown"; }The patch file should be placed at
patches/react-native-image-picker/react-native-image-picker+7.1.2+003+null-check-getMimeType.patchand a corresponding entry added topatches/react-native-image-picker/details.md. This is a one-line null-guard that matches how Android's own documentation specifies the API behaves, and it unblocks the fallbackgetMimeTypeForContentpath that already exists for exactly this scenario.What alternative solutions did you explore? (Optional)
N/A
MelvinBot commentedon Mar 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Android (Samsung Galaxy S25 FE / Android 16), the app crashes after taking a photo via Chat → + → Add attachment → Take photo → OK. This is a regression in v9.3.28-0, reproducible in both staging and production.
What is the root cause of that problem?
The crash is most likely caused by Android 16's 16KB page alignment enforcement combined with
react-native-image-pickerv7.1.2 never having been updated for Android 16 / SDK 36 compatibility.The crash mechanism:
When the user taps "Take photo," the
AttachmentPickercallslaunchCamera(launchCamera.android.ts:12-30), which launches a cameraIntentviareact-native-image-picker'sImagePickerModuleImpl.javausingstartActivityForResult. When the system camera opens in the foreground, the OS may kill the Expensify app process to reclaim memory. After the user taps OK, Android tries to restore the Expensify process, which requires reloading all native.solibraries. If any.sofile has 4KB-aligned ELF segments instead of the 16KB alignment required by Android 16, the process crashes with a native SIGBUS/SIGSEGV.Supporting evidence:
android/build.gradle:6-7:compileSdkVersion = 36,targetSdkVersion = 36) which requires 16KB page alignment on Android 16 devicesreact-native-image-pickerwas never updated for 16KB compatibility — it still targetscompileSdkVersion 33/targetSdkVersion 33(atnode_modules/react-native-image-picker/android/build.gradle:11,29). Issue [Due for payment 2026-03-13] [Due for payment soon?] Enable 16KB memory page size on Android #63871 drove 16KB alignment updates to many libraries (VisionCamera, blob-util, expo-image, onfido, mapbox, react-native-pdf, group-ib-fp, Fresco) butreact-native-image-pickerwas missedAlternative consideration: If the crash is not 16KB-alignment-related, a secondary candidate is a
NullPointerExceptioninUtils.getMimeType()(Utils.java:405) wherecontentResolver.getType(uri)can returnnulland.isBlank()is called without a null check. However, for camera captures, the code uses afile://URI which takes a different code branch, making this less likely.What changes do you think we should make in order to solve the problem?
react-native-image-pickerto a version compatible with 16KB page alignment, or patch the native build to ensure its dependencies are properly aligned. Check if Mobile-Expensify PR [HOLD for payment 2023-01-16] [$1000] Android - Connect Manually -The App can crash after clicking on the back button during manual Bank account flow #13857 already addresses thisUtils.getMimeType()by adding a null check on thecontentResolver.getType(uri)return value atUtils.java:405, either by patching the library or upgrading to a newer version that fixes thisWhat alternative solutions did you explore? (Optional)
react-native-image-pickerentirely: TheIOURequestStepScanflow already usesreact-native-vision-cameradirectly for receipt scanning, which has been updated for 16KB alignment. TheAttachmentPickercould be refactored to use VisionCamera instead, but this is a larger scope changelaunchCameraimplementation: Use the newer Activity Result API (registerForActivityResult) instead of the deprecatedstartActivityForResultpattern inreact-native-image-picker, which may also improve compatibility with Android 16's stricter activity lifecycle handlingNext Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.melvin-bot commentedon Mar 3, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ShridharGoel (
External)melvin-bot commentedon Mar 3, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022028785756915839677
[-]Android - Attachment - App crashes after taking a photo[/-][+][$250] Android - Attachment - App crashes after taking a photo[/+]twilight2294 commentedon Mar 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Android 16 (Samsung Galaxy S25 FE), the app crashes immediately after taking a photo via the attachment picker (+ > Add attachment > Take photo > OK).
What is the root cause of that problem?
The crash is a
NullPointerExceptioninreact-native-image-picker's Utils. After the camera returns a result, the library callsgetImageResponseMap()which callsgetImageDimensions(). InsidegetImageDimensions(),getOrientation()is called at line 160, which returnsexifInterface.getAttribute(ExifInterface.TAG_ORIENTATION)— this can returnnullwhen the EXIF orientation tag is absent from the captured image.The
nullorientation is then passed toneedToSwapDimension()at line 200, which callsorientation.equals(...)on the null value, causing the NPE crash. On Android 16, certain camera implementations no longer guarantee the EXIF orientation tag is written, making this null return consistent.This is distinct from the
getMimeType()NPE identified in MobileMage's proposal. The camera capture flow uses afile://URI (created viaUri.fromFile()at line 211), so thecontent://branch ingetMimeType()wherecontentResolverMimeType.isBlank()can NPE is never reached during camera capture. The actual crash path is:onActivityResult→onAssetsObtained→getResponseMap→getImageResponseMap→getImageDimensions→getOrientationreturns null →needToSwapDimension(null)→ NPE.Additionally,
setOrientation()at line 253 has the same null-unsafe pattern:orientation.equals(...)will NPE if orientation is null.What changes do you think we should make in order to solve the problem?
Add a patch file at
patches/react-native-image-picker/react-native-image-picker+7.1.2+003+null-safe-orientation.patchthat null-guards orientation in bothneedToSwapDimensionandsetOrientation:A corresponding entry should be added to
patches/react-native-image-picker/details.md.What alternative solutions did you explore? (Optional)
MobileMage's proposal targets the
getMimeType()null check oncontentResolverMimeType.isBlank(). While that is a legitimate bug for the gallery/content-picker flow, it is not the crash path for camera capture — camera uses afile://URI which takes a completely different branch ingetMimeType(). That fix alone would not resolve this issue. Ideally both patches should be applied (thegetMimeTypenull guard for gallery picks, and this orientation null guard for camera captures), but the orientation fix is the one that addresses the reported crash scenario.abbasifaizan70 commentedon Mar 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
The app crashes immediately after taking a photo via the attachment picker
What is the root cause of that problem?
When the user opens the system camera from the chat attachment flow, the main activity goes to the background. Android can recreate the activity when the user returns (e.g. due to low memory, “Don’t keep activities” in Developer Options, or normal lifecycle behavior). When the activity is recreated, the system calls
onCreate(savedInstanceState)with a non-null bundle so the activity can restore its state.In
MainActivity.kt, the code callssuper.onCreate(null)instead ofsuper.onCreate(savedInstanceState).App/android/app/src/main/java/com/expensify/chat/MainActivity.kt
Lines 38 to 42 in bf2ae7e
Passing
nulltells the Android framework that there is no saved state, so the activity (and React Native) are treated as a fresh start. That can leave the app in an inconsistent state when the camera result is delivered (e.g. viaonActivityResult). The recreated activity may try to restore or run against torn-down or mismatched UI/bridge state, which can lead to a crash instead of returning to the chat with the photo attached.What changes do you think we should make in order to solve the problem?
Pass
savedInstanceStatetosuper.onCreate()so the activity (and React Native) restore state when the activity is recreated after returning from the camera. That keeps the app in a consistent state when the image picker result is applied and prevents the crash.Location:
App/android/app/src/main/java/com/expensify/chat/MainActivity.ktSolution (code change):
Replace
super.onCreate(null)withsuper.onCreate(savedInstanceState)so that when the activity is recreated after taking a photo, the framework restores the activity state and the app does not crash; the user returns to the chat and the captured image can be attached correctly.169 remaining items
melvin-bot commentedon Sep 24, 2026
Current assignee @mallenexpensify is eligible for the Awaiting Payment assigner, not assigning anyone new.
mallenexpensify commentedon Sep 25, 2026
Payment Summary
Contributor+: @ShridharGoel due $250 via NewDot
Contributor+: @huult due $250 via NewDot
huult commentedon Sep 26, 2026
@mallenexpensify You tagged the wrong person. I’m the C+, not @ShridharGoel. 😄
ShridharGoel commentedon Sep 26, 2026
@mallenexpensify Both have payment due here
mallenexpensify commentedon Sep 28, 2026
paid, summary updated above. Thx.
JmillsExpensify commentedon Oct 14, 2026
$250 approved for @huult
garrettmknight commentedon Oct 19, 2026
$250 approved for @ShridharGoel