Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D AndroidNative: android.os.FileUriExposedException: file:///storage/emulated/0/DCIM/2018-06-05%2020.19.03.jpg exposed beyond app through ClipData.Item.getUri() #16

Open
mjamroz opened this issue Jun 5, 2018 · 9 comments

Comments

@mjamroz
Copy link

mjamroz commented Jun 5, 2018

When im trying to use it on android 25, then i got the error as in the title. Is there any hope it will be working for the newest targets?

anyway, great package. thank you!

@rmallah
Copy link
Contributor

rmallah commented Jun 6, 2018

@mjamroz can you please tell which function is being called , we shall try to fix it.

@mjamroz
Copy link
Author

mjamroz commented Jun 6, 2018

@rmallah Hi, thanks for your answer.

Im calling
ImagePicker.takePhoto()
to get that error. ImagePicker.pickImage() is working correctly.

@rmallah
Copy link
Contributor

rmallah commented Jun 6, 2018 via email

@rmallah
Copy link
Contributor

rmallah commented Jun 6, 2018

Hi @mjamroz ,

ImagePicker.takePhoto() is also included in the demo program. can you compile the demo
program and see if the "Image Picker" Component as displayed in home of the demo
app works.

please note you will have to install quickandroid to compile the demo program,

in the project folder
"androidnative.pri/examples/androidnativeexample" by run

$ qpm install [email protected]

(you have to install qpm if you do not have already)

I did these and in Android-25 ie version: 7.1.x it does work.

regds
mallah.

@mjamroz
Copy link
Author

mjamroz commented Jun 6, 2018

I tried it.

I tested directly of quickandroid

$ qpm install [email protected]
opened quickandroidexample.pro in qtcreator
selected Android_for_armeabi_v7a_GCC_4_9_Qt_5_9_0_for_Android_armv7-Debug to compile
set API 25 in androidmanifest.xml
i had to replace gradle version in gradle-wrapper.properties, because

> Gradle version 2.2 is required. Current version is 3.4. If using the gradle wrapper, try editing the distributionUrl in /home/nme/te/vendor/com/github/benlau/quickandroid/examples/build-quickandroidexample-Android_for_armeabi_v7a_GCC_4_9_Qt_5_9_0_for_Android_armv7-Debug/android-build/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip

compiled and opened on my motorola. After clicking icon with camera i got the same error as in my own application:

D quickandroid.ImagePicker: takePhoto : file:///storage/emulated/0/DCIM/2018-06-06%2020.46.11.jpg
D QuickAndroid: android.os.FileUriExposedException: file:///storage/emulated/0/DCIM/2018-06-06%2020.46.11.jpg exposed beyond app through ClipData.Item.getUri()
D QuickAndroid: 	at android.os.StrictMode.onFileUriExposed(StrictMode.java:1813)
D QuickAndroid: 	at android.net.Uri.checkFileUriExposed(Uri.java:2366)
D QuickAndroid: 	at android.content.ClipData.prepareToLeaveProcess(ClipData.java:845)
D QuickAndroid: 	at android.content.Intent.prepareToLeaveProcess(Intent.java:8989)
D QuickAndroid: 	at android.content.Intent.prepareToLeaveProcess(Intent.java:8974)
D QuickAndroid: 	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1583)
D QuickAndroid: 	at android.app.Activity.startActivityForResult(Activity.java:4229)
D QuickAndroid: 	at android.app.Activity.startActivityForResult(Activity.java:4187)
D QuickAndroid: 	at quickandroid.ImagePicker.takePhoto(ImagePicker.java:89)
D QuickAndroid: 	at quickandroid.ImagePicker$1.onDispatched(ImagePicker.java:41)
D QuickAndroid: 	at quickandroid.SystemDispatcher.emit(SystemDispatcher.java:155)
D QuickAndroid: 	at quickandroid.SystemDispatcher.dispatch(SystemDispatcher.java:66)

Selecting photo from storage works (the same like in my own app), only takePhoto() crashes.

I tested also as you suggested, getting the same error

git clone https://github.com/benlau/androidnative.pri.git
cd androidnative.pri/examples/androidnativeexample/
qpm install [email protected] 
opened pro in qt creator
set API 25 in androidmanisfest
compiled with Android_for_armeabi_v7a_GCC_4_9_Qt_5_9_0_for_Android_armv7-Debug

... and clicking icon to open native camera, i got:

D androidnative.ImagePicker: takePhoto : file:///storage/emulated/0/DCIM/2018-06-06%2020.57.27.jpg
D AndroidNative: android.os.FileUriExposedException: file:///storage/emulated/0/DCIM/2018-06-06%2020.57.27.jpg exposed beyond app through ClipData.Item.getUri()
D AndroidNative: 	at android.os.StrictMode.onFileUriExposed(StrictMode.java:1813)
D AndroidNative: 	at android.net.Uri.checkFileUriExposed(Uri.java:2366)
D AndroidNative: 	at android.content.ClipData.prepareToLeaveProcess(ClipData.java:845)
D AndroidNative: 	at android.content.Intent.prepareToLeaveProcess(Intent.java:8989)
D AndroidNative: 	at android.content.Intent.prepareToLeaveProcess(Intent.java:8974)
D AndroidNative: 	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1583)
D AndroidNative: 	at android.app.Activity.startActivityForResult(Activity.java:4229)
D AndroidNative: 	at android.app.Activity.startActivityForResult(Activity.java:4187)
D AndroidNative: 	at androidnative.ImagePicker.takePhoto(ImagePicker.java:89)
D AndroidNative: 	at androidnative.ImagePicker$1.onDispatched(ImagePicker.java:41)
D AndroidNative: 	at androidnative.SystemDispatcher.emit(SystemDispatcher.java:155)
D AndroidNative: 	at androidnative.SystemDispatcher.dispatch(SystemDispatcher.java:66)

If you need some more info/tests/etc. let me know. I will be happy to help.

@rmallah
Copy link
Contributor

rmallah commented Jun 7, 2018

Relevant Discussion:

https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed/38858040#38858040

we shall try to improve upon it.
I shall have access to my android 7.1 handset after a couple of hours.

regds
mallah.

@mjamroz
Copy link
Author

mjamroz commented Jun 7, 2018

I would say it will be painful to replace that since qt/qml uses file://. Maybe rather solution from https://stackoverflow.com/a/42437379 ?

@rmallah
Copy link
Contributor

rmallah commented Jun 7, 2018

@mjamroz it should be possible to find a proper solution . I don't feel its related to usage
of file:// by qt/qml. I am working on it should be able to find a solution based on
https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en
which is essentially the same info.

thanks for reporting it . For the time being you may use some workaround.
i shall be able to see to it only after a few days.

regds
mallah.

@parshwa1596
Copy link

android.os.FileUriExposedException: file:///storage/emulated/0/Documents/Patidar.pdf exposed beyond app through Intent.getData()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1960)
at android.net.Uri.checkFileUriExposed(Uri.java:2362)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9901)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9853)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1612)
at android.app.Activity.startActivityForResult(Activity.java:4555)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.app.Activity.startActivityForResult(Activity.java:4513)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
at android.app.Activity.startActivity(Activity.java:4874)
at android.app.Activity.startActivity(Activity.java:4842)
at com.patidar.marriagebureau.Activities.Printprofile.previewPdf(Printprofile.java:501)
at com.patidar.marriagebureau.Activities.Printprofile.createPdf(Printprofile.java:486)
at com.patidar.marriagebureau.Activities.Printprofile.createPdfWrapper(Printprofile.java:416)
at com.patidar.marriagebureau.Activities.Printprofile.access$000(Printprofile.java:65)
at com.patidar.marriagebureau.Activities.Printprofile$1.onClick(Printprofile.java:171)

i got these error what can i do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants