coomar2841 / image-chooser-library

An Easy Image/Video Chooser Library for your Android Apps
646 stars 193 forks source link

FileNotFoundException (NOENT) when picking local file #69

Closed ruckus closed 9 years ago

ruckus commented 9 years ago

Library version: 1.4.3

Works great running on Galaxy Nexus 4.3

On a LG device running 4.4 when I choose an image from my local camera roll my Activity#onError is being called with reason:

java.io.FileNotFoundException: /storage/emulated/0/bimagechooser/1429031333305.jpg: open failed: ENOENT (No such file or directory)

In my case I dont care about creating thumbnails, I've tried both:

mImageChooserManager = new ImageChooserManager(this, ChooserType.REQUEST_PICK_PICTURE, false);

and

mImageChooserManager = new ImageChooserManager(this, ChooserType.REQUEST_PICK_PICTURE);

Same issue.

Full logcat messages:

I/ImageChooserManager( 3110): File: content://com.android.providers.media.documents/document/image%3A132
I/ImageProcessorThread( 3110): Processing Image File: content://com.android.providers.media.documents/document/image%3A132
I/MediaProcessorThread( 3110): Image Uri: content://com.android.providers.media.documents/document/image%3A132
I/MediaProcessorThread( 3110): Google photos Started
I/MediaProcessorThread( 3110): URI: content://com.android.providers.media.documents/document/image%3A132
I/MediaProcessorThread( 3110): Extension: .jpg
I/MediaProcessorThread( 3110): Display Name: 0414150939.jpg
I/MediaProcessorThread( 3110): Size: 615679
I/Adreno-EGL( 3110): <qeglDrvAPI_eglInitialize:385>: EGL 1.4 QUALCOMM build:  ()
I/Adreno-EGL( 3110): OpenGL ES Shader Compiler Version: E031.24.00.01
I/Adreno-EGL( 3110): Build Date: 12/27/13 Fri
I/Adreno-EGL( 3110): Local Branch: qualcomm_only
I/Adreno-EGL( 3110): Remote Branch:
I/Adreno-EGL( 3110): Local Patches:
I/Adreno-EGL( 3110): Reconstruct Branch:
I/Vold    (  322): [LGE][VOLD][NetlinkHandler.cpp][onEvent()] subsys:cpu, action:0
W/System.err( 3110): java.io.FileNotFoundException: /storage/emulated/0/bimagechooser/1429031333305.jpg: open failed: ENOENT (No such file or directory)
W/System.err( 3110):    at libcore.io.IoBridge.open(IoBridge.java:462)
W/System.err( 3110):    at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
W/System.err( 3110):    at java.io.FileOutputStream.<init>(FileOutputStream.java:128)
W/System.err( 3110):    at java.io.FileOutputStream.<init>(FileOutputStream.java:117)
W/System.err( 3110):    at com.kbeanie.imagechooser.threads.MediaProcessorThread.processGooglePhotosMedia(MediaProcessorThread.java:395)
W/System.err( 3110):    at com.kbeanie.imagechooser.threads.ImageProcessorThread.processImage(ImageProcessorThread.java:98)
W/System.err( 3110):    at com.kbeanie.imagechooser.threads.ImageProcessorThread.run(ImageProcessorThread.java:57)
W/System.err( 3110): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
W/System.err( 3110):    at libcore.io.Posix.open(Native Method)
W/System.err( 3110):    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
W/System.err( 3110):    at libcore.io.IoBridge.open(IoBridge.java:446)
W/System.err( 3110):    ... 6 more
W/System.err( 3110): java.io.FileNotFoundException: /storage/emulated/0/bimagechooser/1429031333305.jpg: open failed: ENOENT (No such file or directory)
W/System.err( 3110):    at libcore.io.IoBridge.open(IoBridge.java:462)
W/System.err( 3110):    at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
W/System.err( 3110):    at java.io.FileOutputStream.<init>(FileOutputStream.java:128)
W/System.err( 3110):    at java.io.FileOutputStream.<init>(FileOutputStream.java:117)
W/System.err( 3110):    at com.kbeanie.imagechooser.threads.MediaProcessorThread.processGooglePhotosMedia(MediaProcessorThread.java:395)
W/System.err( 3110):    at com.kbeanie.imagechooser.threads.ImageProcessorThread.processImage(ImageProcessorThread.java:98)
W/System.err( 3110):    at com.kbeanie.imagechooser.threads.ImageProcessorThread.run(ImageProcessorThread.java:57)
W/System.err( 3110): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
W/System.err( 3110):    at libcore.io.Posix.open(Native Method)
W/System.err( 3110):    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
W/System.err( 3110):    at libcore.io.IoBridge.open(IoBridge.java:446)
ruckus commented 9 years ago

Can replicate this in the simulator on a 4.4 device. With my sample size = 2 it appears to be any 4.4 device.

ruckus commented 9 years ago

I downloaded the sample app from the Play Store and it works on my LG device which fails to work when integrated into my Activity - Activity#onError called every time.

I took ImageChooserActivity from the sample app and dropped it into my app as-is and yields the same issue - FileNotFoundException.

I tried using 1.4.02 and same issue.

At this point I'm at a loss as to why the sample app works but when integrated into my app it does not. ImageChooserActivity with no changes also fails. So its hard for me to see if I'm doing something wrong in my app.

coomar2841 commented 9 years ago

That's strange. Do you have permission to WRITE_EXTERNAL_STORAGE for your application?

ruckus commented 9 years ago

I do, along with READ_EXTERNAL_STORAGE:

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"  />
coomar2841 commented 9 years ago

FileNotFoundException: /storage/emulated/0/bimagechooser/1429031333305.jpg:

When initializing the class, do you specify a different folder name by any chance?

ruckus commented 9 years ago

I've tried all variations. I first started with:

new ImageChooserManager(this, ChooserType.REQUEST_PICK_PICTURE);

I then tried

new ImageChooserManager(this, ChooserType.REQUEST_PICK_PICTURE, "myapp");

I see the ImageChooserActivity uses:

        imageChooserManager = new ImageChooserManager(this,
                ChooserType.REQUEST_PICK_PICTURE, "myfolder", true);
ruckus commented 9 years ago

I took the sources of com.kbeanie.imagechooser and dropped them into my app, removed the gradle declaration for the library and the app works.

So essentially master as of this moment is working.

coomar2841 commented 9 years ago

Ok. I have been refactoring a bit on the dev branch, may be I broke something there.

coomar2841 commented 9 years ago

Hope this is not an issue anymore. Please re-open in case you still have issues with this.