Yalantis / uCrop

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

BitmapLoadTask Android 7.0 Uri Error #268

Closed tatsuyuki25 closed 7 years ago

tatsuyuki25 commented 7 years ago

In BitmapLoadTask

outputStream = new FileOutputStream(new File(outputUri.getPath()));
//must be convert to 
outputStream = mContext.getContentResolver().openOutputStream(outputUri);

Because Android 7.X can not use Uri to File

KucherenkoIhor commented 7 years ago

Hello, @tatsuyuki25 you are right. I think that FileProvider can resolve this. We need to update our project. Can you provide logcat with this crash?

tatsuyuki25 commented 7 years ago
W/System.err: java.io.FileNotFoundException: No such file or directory
W/System.err:     at android.os.Parcel.openFileDescriptor(Native Method)
W/System.err:     at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:253)
W/System.err:     at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:199)
W/System.err:     at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:932)
W/System.err:     at android.content.ContentResolver.openOutputStream(ContentResolver.java:702)
W/System.err:     at android.content.ContentResolver.openOutputStream(ContentResolver.java:678)
W/System.err:     at com.yalantis.ucrop.task.BitmapCropTask.saveImage(BitmapCropTask.java:170)
W/System.err:     at com.yalantis.ucrop.task.BitmapCropTask.crop(BitmapCropTask.java:151)
W/System.err:     at com.yalantis.ucrop.task.BitmapCropTask.doInBackground(BitmapCropTask.java:94)
W/System.err:     at com.yalantis.ucrop.task.BitmapCropTask.doInBackground(BitmapCropTask.java:35)
W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:292)
W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err:     at java.lang.Thread.run(Thread.java:818)

In BitmapCropTask should not be used Uri.fromFile

duanxinyuan commented 7 years ago

outputStream = new FileOutputStream(new File(outputUri.getPath())); //must be convert to outputStream = mContext.getContentResolver().openOutputStream(outputUri);

这个代码可以修改掉提交一下吗,在2.2.1的更新记录里没有看到