Mariovc / ImagePicker

Android library to easily pick an image from gallery or camera app. The users can select their prefered gallery/camera app on a unique Intent. Initial gist:
https://gist.github.com/Mariovc/f06e70ebe8ca52fbbbe2
Apache License 2.0
158 stars 52 forks source link

Crashes in Android O #23

Closed nidhinprathap closed 6 years ago

nidhinprathap commented 7 years ago

Here is the crash log from Android O beta :- It crashes when you are trying to show the picker

android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.sample.picker/cache/tempImage exposed beyond app through ClipData.Item.getUri() at android.os.StrictMode.onFileUriExposed(StrictMode.java:1932) at android.net.Uri.checkFileUriExposed(Uri.java:2348) at android.content.ClipData.prepareToLeaveProcess(ClipData.java:935) at android.content.Intent.prepareToLeaveProcess(Intent.java:9718) at android.content.Intent.prepareToLeaveProcess(Intent.java:9724) at android.content.Intent.prepareToLeaveProcess(Intent.java:9703) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1609) at android.app.Activity.startActivityForResult(Activity.java:4462) at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79) at android.app.Activity.startActivityForResult(Activity.java:4420) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859) at com.mvc.imagepicker.ImagePicker.pickImage(ImagePicker.java:92)

nidhinprathap commented 7 years ago

Have fixed and updated the code in the given forked repo

https://github.com/nidhinprathap/ImagePicker

Mariovc commented 7 years ago

Thank you very much for your collaboration @nidhinprathap . I couldn't test your changes yet on Android O, but I hope to do it soon. If someone else can test it and check everything is ok before merge this will be helpful.

GrenderG commented 7 years ago

You can use this as a workaround untils it's fixed (put it where you are using the library):

StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
metzing commented 7 years ago

Hi,

I tested both the original and the forked repo on Android O. I found that while the original indeed crashes with the trace @nidhinprathap wrote, the forked version works like a charm (after granting storage permission manually in App Settings).

Thus I recommend merging the pull request, @Mariovc.

In the meantime, the workaround posted by @GrenderG seems to be working as well.

Mariovc commented 7 years ago

@metzing it is not working as expected. I get some errors. Check this out on #24 The workaround of @GrenderG may work but it is not the right way to do this.

mostafaaddam commented 7 years ago

@Mariovc the updated version worked on my pixel except for the camera part once I launch the camera I take a pic and press the correct button the camera app crashes not the app. any suggestions?

avierose commented 7 years ago

Can anyone confirm if this issue with android O has been fixed yet?

Mariovc commented 6 years ago

Fixed with 1.2.1 version from PR #40

Mariovc commented 6 years ago

There was a mistake in 1.2.1, try it now with 1.2.2, please