Yalantis / uCrop

Image Cropping Library for Android
https://yalantis.com/blog/introducing-ucrop-our-own-image-cropping-library-for-android/
11.86k stars 2.16k forks source link

FileUtils.java accesses undefined column _data #104

Closed chrisdoc closed 8 years ago

chrisdoc commented 8 years ago

Commit Fixed resize logic for cropping original images 9f13185665115dca8bd6603a256b7528fa81a7cf introduces a new FileUtils.java helper that tries to access the column _data of a MediaStore which results in a thrown IllegalArgumentException because the exception is not catched.

Test devices:

java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:309)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: column '_data' does not exist
        at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:333)
        at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:87)
        at com.yalantis.ucrop.util.FileUtils.getDataColumn(FileUtils.java:224)
        at com.yalantis.ucrop.util.FileUtils.getPath(FileUtils.java:315)
        at com.yalantis.ucrop.task.BitmapLoadTask.processInputUri(BitmapLoadTask.java:163)
        at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:84)
        at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:40)
        at android.os.AsyncTask$2.call(AsyncTask.java:295)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
shliama commented 8 years ago

Strange, I haven't received any of that yet on my projects. But I'll add fix in the next patch.

chrisdoc commented 8 years ago

Any progress @shliama

shliama commented 8 years ago

@chrisdoc please try to use library version 2.1.0. Above exception now should be caught properly.

yukuku commented 8 years ago

When accessing content uri, you should not try to get the path of the actual file. So you don't need read external storage permissions.

CeccoCQ commented 8 years ago

I've the v2.1 and still have the error.

shliama commented 8 years ago

It crashes the app? I've added catch clause for this exception but it goes to logs.

IbraTq commented 7 years ago

i have the v2.2 and still have the error please check this:

http://crashes.to/s/edce6405f76