Yalantis / uCrop

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

i got an Exception while crop image from camera on android N #303

Closed Salmancs43 closed 6 years ago

Salmancs43 commented 7 years ago

When taking picture from camera and after cropping when i click on save it crashes.

mawshd commented 7 years ago

I also getting same error on Nougat. On Activity result I am getting RESULT_ERROR = 96 always. Please suggest me a solution. Before Nougat platform its working fine.

AnkushWalia commented 7 years ago

yes its is issue of file exposed exception. i have changed this code with compatible with nougat. you check it out from this link https://github.com/AnkushWalia/EasyAndroidDevelopment/tree/master/ucrop

sarvajeet294 commented 7 years ago

Yalantis, Please resolve this issue. I am also facing this issue.

sarvajeet294 commented 7 years ago

Can you take a look on this issue on priority??

AnkushWalia commented 7 years ago

have u check that my code in android N??

sarvajeet294 commented 7 years ago

Yes, I checked it. But I have a huge code and to change the library will take a lot of time. Thats why I was hoping if the issue gets resolved in this one only.

AnkushWalia commented 7 years ago

ok ok dear,,, but do you know one thing,,what is issue you have???,, so listen android N having issue of FIle Exposed Exception. so you just change the Uri.Fromfile() method replace to File Provider to get uri of image then your code will be working.

rahul107 commented 7 years ago

i can't crop capture image. i using ucrop library please give some help.

sarvajeet294 commented 7 years ago

Thanks Ankush, I will surely try it and let you know.

sarvajeet294 commented 7 years ago

Ankush, your lib worked like a charm. Now will have to change the whole code.

AnkushWalia commented 7 years ago

Thnx

sarvajeet294 commented 7 years ago

Ankush: Hi, As I said I used your lib. But I am facing another issue in some mobiles like Samsung J7 or moto G 2nd gen etc.

The issue is FATAL EXCEPTION: AsyncTask #7 Process: com.vastuhfc.ksb.pulse_app, PID: 26929 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: Failed to find configured root that contains /storage/4534-1D1B/DCIM/Camera/20170716_000214.jpg at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:711) at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:400) at com.yalantis.ucrop.task.BitmapLoadTask.processInputUri(BitmapLoadTask.java:193) at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:99) at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:50) 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) 

Please take a look on it asap.

AnkushWalia commented 7 years ago

Ok @sarvajeet294 I will check it out after I will surely update you.

sarvajeet294 commented 7 years ago

@AnkushWalia Did you find anything in it? I am facing huge problem because of it hence I am on your tail. Sorry for bothering you.

AnkushWalia commented 7 years ago

No @sarvajeet294 i didn't get the exception. it is a mainly a thread exception so you got illegal argument exception so dont worry its not come every time.

sarvajeet294 commented 7 years ago

@AnkushWalia In my case in some mobiles, when you select image from Gallery it comes 90% of the times. What do you think, what should I do about it?

imhashir commented 7 years ago

@AnkushWalia Thanks a lot. Your solution worked.

However I had to made a little change in your code to get it to work on my App. In FileProvider.getUriFrlmFile, I had to append ".provider" to 2nd parameter. Everything worked fine then. Maybe it's due to my app configurations.

Btw Thanks a lot for your modified library.

AnkushWalia commented 7 years ago

Thank you @imhashir

quensh93 commented 6 years ago

this link is now found https://github.com/AnkushWalia/EasyAndroidDevelopment/tree/master/ucrop i still have this issue

mohitajwani commented 6 years ago

@AnkushWalia I am unable to view this link that has been shared by you. Can you please verify? Still facing the Null Pointer Issue for Nougat and above devices.

AnkushWalia commented 6 years ago

Hello which issue u hv got please metion it my gihub directory on issue tab Thanks

On Sat, 2 Dec 2017 at 5:29 PM, quensh93 notifications@github.com wrote:

this link is now found https://github.com/AnkushWalia/EasyAndroidDevelopment/tree/master/ucrop i still have this issue

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Yalantis/uCrop/issues/303#issuecomment-348687450, or mute the thread https://github.com/notifications/unsubscribe-auth/Ab3bz-_nsubsJ5o6tfLFy80oTbVHO1i9ks5s8TuvgaJpZM4NiaJ7 .

mohitajwani commented 6 years ago

@AnkushWalia You had shared a link https://github.com/AnkushWalia/EasyAndroidDevelopment/tree/master/ucrop to view the corrections. I have been to your repository and seen that uCrop library is not being used. Instead, you are using imagepickcrop library. I am facing issue with uCrop and needed help on this issue of File Provider.

AnkushWalia commented 6 years ago

Mohit my image crop library is same of crop.. u have to just add my library dependecy on your project and then check it

ucdevinda123 commented 6 years ago

In Application class onCreate method used this working perfectly !

if(Build.VERSION.SDK_INT>=24){ try{ Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure"); m.invoke(null); }catch(Exception e){ e.printStackTrace(); } }

Legementarion commented 6 years ago

Fixed at Ucrop 2.2.2