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

Camera MediaPicker throws error about write external storage on api 31 #13119

Closed
williambuchanan2 opened this issue Feb 5, 2023 · 3 comments
Closed
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android 🤖 t/bug Something isn't working

Comments

@williambuchanan2
Copy link

williambuchanan2 commented Feb 5, 2023

Description

Using the camera in Maui doesn't seem to work due to permission issues. Using MediaPicker example from the Microsoft documents doesn’t work. Throws error as it tries to access storage.

Error: Microsoft.Maui.ApplicationModel.PermissionException: 'StorageWrite permission was not granted: Denied'

Note that if I don't request StorageWrite permission I get the following error:

Microsoft.Maui.ApplicationModel.PermissionException: 'You need to declare using the permission: android.permission.WRITE_EXTERNAL_STORAGE in your AndroidManifest.xml'

So, bit of a catch 22 situation...

Steps to Reproduce

Do exactly what this page shows:

https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/device-media/picker

Android.Manifest entries:

   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACTION_OPEN_DOCUMENT" />
    <uses-permission android:name="android.permission.ACTION_OPEN_DOCUMENT_TREE" />

    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

    <!-- Required to maintain app compatibility. -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

    <queries>
        <intent>
            <action android:name="android.media.action.IMAGE_CAPTURE" />
        </intent>
    </queries>

Code:

   private async void TakePhotoPressed()
    {
        MediaPickerOptions options = new MediaPickerOptions();
        options.Title = "Add Attachment";
       
        FileResult result = await MediaPicker.Default.CapturePhotoAsync(options);
        ...
    }

Link to public reproduction project repository

?

Version with bug

6.0.312

Last version that worked well

Sounds like it has never worked, based on the number of people reporting it.

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android api 31

Did you find any workaround?

No

Relevant log output

None
@williambuchanan2 williambuchanan2 added the t/bug Something isn't working label Feb 5, 2023
@williambuchanan2 williambuchanan2 changed the title Camera throws error about write external storage on api 33 Camera MediaPicker throws error about write external storage on api 31 Feb 5, 2023
@jsuarezruiz jsuarezruiz added area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android 🤖 labels Feb 6, 2023
@jsuarezruiz
Copy link
Contributor

Already fixed by #12914

@mattleibow
Copy link
Member

Duplicate of #11275

@mattleibow mattleibow marked this as a duplicate of #11275 Feb 7, 2023
@mattleibow
Copy link
Member

We fixed it a few weeks ago and backported to net7, unfortunately it missed the release so will go out with the next servicing release.

One workaround is to set your app to target one version back: #11275 (comment)

Very unfortunate to not get this out sooner, I know.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants