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] IOException: open failed: ENOENT (No such file or directory)

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

13reactions
yfukscommented, Jan 7, 2016

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();
}
10reactions
yfukscommented, Jan 7, 2016

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: open failed: ENOENT (No such file or directory)
The example given in the API reference has this line: // Make sure the Pictures directory exists. path.mkdirs(); . Are you sure the...
Read more >
Android : Error: open failed: ENOENT (No such file or directory)
Android : Error: open failed : ENOENT ( No such file or directory ) [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >
open failed: ENOENT (No such file or directory) exception ...
The ENOENT (No such file or directory) error may occur in application, If the application do not have storage permission. We suggest you...
Read more >
Runtime Error - open failed: ENOENT (No such file or directory)
Hi, I have a simple project. Running well in Companion But, after build apk and installing it to my phone (Android 11), a...
Read more >
open failed enoent (no such file or directory) android 11 Code ...
ENOENT : no such file or directory, open 'android\app\src\main\assets\index.android.bundle'. An unhandled exception occurred: ENOENT: no such file or directory, ...
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