react-native-image-picker: [Android] IOException: open failed: ENOENT (No such file or directory)

when I pick up a image from system,I got this error:

W/System.err( 5279): java.io.IOException: open failed: ENOENT (No such file or directory)
W/System.err( 5279):    at java.io.File.createNewFile(File.java:941)
W/System.err( 5279):    at com.imagepicker.ImagePickerModule.getResizedImage(ImagePickerModule.java:331)
W/System.err( 5279):    at com.imagepicker.ImagePickerModule.onActivityResult(ImagePickerModule.java:245)
W/System.err( 5279):    at com.imagepicker.ImagePickerPackage.handleActivityResult(ImagePickerPackage.java:46)
W/System.err( 5279):    at com.jarvis.MainActivity.onActivityResult(MainActivity.java:65)
W/System.err( 5279):    at android.app.Activity.dispatchActivityResult(Activity.java:6139)
W/System.err( 5279):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3535)
W/System.err( 5279):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3582)
W/System.err( 5279):    at android.app.ActivityThread.access$1300(ActivityThread.java:144)
W/System.err( 5279):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1327)
W/System.err( 5279):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 5279):    at android.os.Looper.loop(Looper.java:135)
W/System.err( 5279):    at android.app.ActivityThread.main(ActivityThread.java:5221)
W/System.err( 5279):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 5279):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 5279):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
W/System.err( 5279):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
W/System.err( 5279): Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
W/System.err( 5279):    at libcore.io.Posix.open(Native Method)
W/System.err( 5279):    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
W/System.err( 5279):    at java.io.File.createNewFile(File.java:934)
W/System.err( 5279):    … 16 more
W/System.err( 5279):    at com.jarvis.MainActivity.onActivityResult(MainActivity.java:65)
W/System.err( 5279):    at android.app.Activity.dispatchActivityResult(Activity.java:6139)
W/System.err( 5279):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3535)
W/System.err( 5279):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3582)
W/System.err( 5279):    at android.app.ActivityThread.access$1300(ActivityThread.java:144)
W/System.err( 5279):    at android.app.ActivityThread$H.handleMessage(Activity

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Ok, i maybe found something, can you tell me if you have a picture directory on your device ?

In the module try to replace android/src/main/java/com/imagepicker/ImagePickerModule.java line 326 :

File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + filname +".jpg");
try {
  f.createNewFile();
} catch (IOException e) {
  e.printStackTrace();
}

into :

File path = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES);
File file = new File(path, filname +".jpg");
try {
  // Make sure the Pictures directory exists.
  path.mkdirs();

  f.createNewFile();
} catch (IOException e) {
  e.printStackTrace();
}

What kind of image ? (photo, facebook, dropbox…)

I look into this issues and i find the folowing : http://stackoverflow.com/a/11620848 We actually write our file in external storage

try to add the folowing in your AndroidManifest

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

If that don’t work try to reproduce multiple times, if that work once then work everytime it couldmaybe say that the module need to create image in a custom local directory

when Download area is unselectable, I click the photo,I got the following error:

AUDIO_OUTPUT_FLAG_FAST denied by client

I am picking up a photo from filesystem. I have already add the following permission:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

but the same error. btw,I am downloading some jpg ,and when I pick up the jpg file, the Download area is unselectable. and when I pick up photo from Gallery, I got the error.