Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Bug] Still unable to use MediaPicker ImageCapture on Android without declaring WRITE_EXTERNAL_STORAGE permissions in manifest #2037

Closed
plebnz opened this issue Aug 19, 2022 · 7 comments · Fixed by #2073
Labels
bug Something isn't working

Comments

@plebnz
Copy link

plebnz commented Aug 19, 2022

Description

Found in Xamarin Essentials 1.7.3 on Android 11 targeting SDK v31

MediaPicker Image Capture still requires WRITE_EXTERNAL_STORAGE in the manifest otherwise i get a "You need to declare using the permission: android.permission.WRITE_EXTERNAL_STORAGE in your AndroidManifest.xml"

All I want is to capture an image and post it to a server without writing to external storage - Why cant we have the option to write/cache to directories that do not require this permission?

Update: For now I have forked this project and deleted line 59 from the MediaPicker.android file in the project.
await Permissions.EnsureGrantedAsync<Permissions.StorageWrite>(); <-- Deleted

I have compiled the forked project and added it to my application and I can now take pictures and post to server using app cache and no reqauirement to add WRITE_EXTERNAL_STORAGE to manifest.

I feel that i missing something here, some questions I have

  • What happens if I attempt to run this application on an older android OS.
  • Am i supposed to be using maxSDk on the in the manifest on the use-permission for external storage

I dont think the docs are very clear around how this should be handling it and I'm pretty sure I have misunderstood something and I'm just not using the official package correctly in my application correctly so happy to be corrected and delete this bug report as required.

@plebnz plebnz added the bug Something isn't working label Aug 19, 2022
@plebnz
Copy link
Author

plebnz commented Sep 26, 2022

Looks like could be sorted at same time #2041

@avii-7
Copy link

avii-7 commented Nov 7, 2022

Can you please mention the steps of compiling and adding the modified project.

@plebnz
Copy link
Author

plebnz commented Nov 7, 2022

@avii-7

I created a fork which can be found here - though it might be out of date now https://github.com/plebnz/Essentials

You can either clone the latest offical or use mine. If you use the official solution, and it has not yet been fixed, you'll need to delete or remove the line as mentioned in the issue description. The fork already has this done.

  1. Once you have a local copy with the line removed/commented, you can perform a release build to output the DLL libraries.
  2. Copy the locally built xamarin essential dll to you xamarin project. I created a lib directory and placed it in there.
  3. Remove the official xamarin essentials nuget package from the project
  4. Add a reference to the imported DLL to replace the official package with the locally built dll

Boom, you should now be up and running.

@samir05051994
Copy link

hi @jamesmontemagno @jfversluis
The CapturePhotoAsync is not working in android 13 error is "You don't have Storage Write Permission"

I think this bug is due to the CapturePhotoAsync method still having Storage write permission checking please help us to fix this

image

@samir05051994
Copy link

samir05051994 commented Jan 26, 2023 via email

@plebnz
Copy link
Author

plebnz commented Jan 29, 2023

When will this fix be available via the nuget packages?

@suhas100
Copy link

@jamesmontemagno it is getting crashing on Android 13 Please suggest any work around its very crucial

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants