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.

[expo-image-picker] FileUriExposedException: Failure delivering result ResultInfo{} to activity

See original GitHub issue

🐛 Bug Report

An aplication crashed with next error when using launchCameraAsync() fcuntion on Android!

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.testdemo, PID: 1614
    java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=13, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.testdemo/com.testdemo.MainActivity}: android.os.FileUriExposedException: file:///data/user/0/com.testdemo/cache/ImagePicker/9889d105-92cd-4880-b652-e83b82e66565.jpg exposed beyond app through ClipData.Item.getUri()
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4584)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4626)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:6981)
        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:1445)
     Caused by: android.os.FileUriExposedException: file:///data/user/0/com.testdemo/cache/ImagePicker/9889d105-92cd-4880-b652-e83b82e66565.jpg exposed beyond app through ClipData.Item.getUri()
        at android.os.StrictMode.onFileUriExposed(StrictMode.java:1978)
        at android.net.Uri.checkFileUriExposed(Uri.java:2371)
        at android.content.ClipData.prepareToLeaveProcess(ClipData.java:966)
        at android.content.Intent.prepareToLeaveProcess(Intent.java:10902)
        at android.content.Intent.prepareToLeaveProcess(Intent.java:10887)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1667)
        at android.app.Activity.startActivityForResult(Activity.java:4688)
        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
        at android.app.Activity.startActivityForResult(Activity.java:4646)
        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
        at expo.modules.imagepicker.ImagePickerModule.startActivityOnResult(ImagePickerModule.java:754)
        at expo.modules.imagepicker.ImagePickerModule.launchCameraWithPermissionsGranted(ImagePickerModule.java:201)
        at expo.modules.imagepicker.ImagePickerModule.access$000(ImagePickerModule.java:60)
        at expo.modules.imagepicker.ImagePickerModule$1.onPermissionsResult(ImagePickerModule.java:156)
        at expo.modules.permissions.PermissionsService$1.onPermissionResult(PermissionsService.java:56)
        at org.unimodules.adapters.react.services.UIManagerModuleWrapper$5.onRequestPermissionsResult(UIManagerModuleWrapper.java:217)
        at com.reactnativenavigation.NavigationActivity.onRequestPermissionsResult(NavigationActivity.java:117)
        at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7940)
        at android.app.Activity.dispatchActivityResult(Activity.java:7762)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4577)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4626) 
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:6981) 
        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:1445) 

Environment

  React Native Environment Info:
    System:
      OS: Linux 4.15 Linux Mint 19.1 (Tessa)
      CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
      Memory: 1.44 GB / 15.51 GB
      Shell: 2.7.1 - /usr/bin/fish
    Binaries:
      Node: 10.15.3 - /usr/bin/node
      Yarn: 1.15.2 - ~/.yarn/bin/yarn
      npm: 6.9.0 - /usr/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    npmPackages:
      react-native: ^0.59.5 => 0.59.5 
    npmGlobalPackages:
      expo-image-picker: 4.0.0
      react-native-unimodules: 0.3.0
      react-native-navigation: 2.18.4
      create-react-native-web-app: 0.1.14
      react-native-cli: 2.0.1
      react-native-create-library: 3.1.2
      ...

Steps to Reproduce

git clone https://github.com/retyui/expo-bag
cd expo-bag 
yarn start;
react-native run-android

Then press Button and provide access permissions

Expected Behavior

Will be opened a camera

Actual Behavior

An aplication crashed always when call launchCameraAsync

Reproducible Demo

https://github.com/retyui/expo-bag

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
AlbertVilaCalvocommented, May 13, 2019

@cruzach FYI the PR #3734 doesn’t fix the issue for me - see https://github.com/expo/expo/issues/3706#issuecomment-491611991

1reaction
cruzachcommented, May 13, 2019

Hey @retyui,

You need to get Permissions for CAMERA and CAMERA_ROLL first.

Read through the ImagePicker docs for lots more info 😄

-Charlie

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failure delivering result ResultInfo when trying to choose an ...
I have created this activity which has - upload and choose buttons. Found where the problem occurs - in my onActivityResult function on...
Read more >
android camera : Failure delivering result ResultInfo{who=null ...
Android : android camera : Failure delivering result ResultInfo {who=null, request=0, result=-1, data=null} to activity [ Beautify Your ...
Read more >
Failure delivering result ResultInfo{who=null, request ... - NextPit
What I am working on is an activity where the user can press a button to take a picture. This picture will then...
Read more >
Android – Failure delivering result ResultInfo{who=null ...
Android – Failure delivering result ResultInfo{who=null, request=0, result=-1, ... Intent data) { Bitmap bitmap = null; if (resultCode == Activity.
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