Xam.Plugin.Media not allowing permissions for android

Hi, i've been building an app for the past 8 months and never had any camera problems. I've been able to take images with the camera without any problems. I then wanted to test an apk so id archived the app and created the adhoc etc. the app installed without a problem. but the taking an image with the camera did not work

so i went back to debugging mode and went to test the app and again the camera did not work. As i had not updated the xam.plugin.media by james montemango for a while i decieded to upgrade the nuget and added the extra info as james says to use

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

and also set the complile and target version to api 23 marshmellow

i keep getting this error which clicking the button to open the camera

Java.Lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity clip={text/uri-list U:file:///storage/emulated/0/Android/data/carraradirectoryapp.carraradirectoryapp/files/Pictures/Sample/test.jpg} (has extras) } from ProcessRecord{7f6dc9e 32591:carraradirectoryapp.carraradirectoryapp/u0a181} (pid=32591, uid=10181) with revoked permission android.permission.CAMERA

if i uninstall the app when i click the button for the camera i do get asked for permission to use the camera. once i choose allow this error appears.

upon debugging the app again i dont get asked about permissions but only get the same error.

i have included the CAMERA permission in the manifest

any ideas?

thanks

Answers

  • markmunizmarkmuniz USUniversity ✭✭

    Were you able to come up with a solution for this? I'm having the same exact issue.

  • CostasAletrariCostasAletrari USMember ✭✭

    Hay mark, funny enough ive just started building another app for a client. and bank ive run into the same problem again. in the previous app i actually fixed it but cant remember what id done to solve the error.

    Im now going to currently tackle this problem again il let you know my solution on how to fix.

    Had you worked it out?

    thanks

  • CostasAletrariCostasAletrari USMember ✭✭

    again not sure why i cant access the camera.

    I have the target and compile pointing to api 23

    i've included the WRITE_EXTERNAL_STORAGE & READ_EXTERNAL_STORAGE and CAMERA permissions in the minifest

    i have included

    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
    {
    PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    to the MainActivity , made sure that the package is installed in the PCL and Android and IOS packages.

    but still will not grant me permissions to use the camera.

    ideas?

  • CostasAletrariCostasAletrari USMember ✭✭

    so what i had to do was goto Settings -> Apps -> your app -> funny enough the camera permission was turned off. once i turned it on it worked

    but why should that happen, when my users go to use the app they shouldn't have to do that, maybe it was becuase i included

     public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)
        {
            PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    

    after the first inital install, i will check this out

    hope this help someone

    found at http://stackoverflow.com/questions/32789027/android-m-camera-intent-permission-bug

  • TEastmanTEastman USMember ✭✭

    @CostasAletrari said:
    so what i had to do was goto Settings -> Apps -> your app -> funny enough the camera permission was turned off. once i turned it on it worked

    but why should that happen, when my users go to use the app they shouldn't have to do that, maybe it was becuase i included

     public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Android.Content.PM.Permission[] grantResults)
        {
            PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    

    after the first inital install, i will check this out

    hope this help someone

    found at http://stackoverflow.com/questions/32789027/android-m-camera-intent-permission-bug

    Did you ever solve this?

    I am running into the same (similar?) issue. However, when I go into settings, I don't even see the camera option available to turn back on. It only shows the storage option.

    Everything works fine in the iOS app, and the pick photo potion works in the android app, just not the take photo.

  • CostasAletrariCostasAletrari USMember ✭✭
    edited July 2017

    Hi @TEastman i managed to get this working by the help of @JamesMontemagno , hope this helps you out.

    https://forums.xamarin.com/discussion/comment/283324#Comment_283324

    not sure why you can see your camera options from the app permissions in the app permission settings

  • coder_rana007coder_rana007 USMember ✭✭
    edited October 2018

    i have add everything but getting same issue on andorid 8.1 version but working on andorid 5.1 version
    how can i solve this?

  • Hi, I've been building an app for the past 8 months and never had any camera problems. I've been able to take images with the camera without any problems. I then wanted to test an apk so I archived the app and created the adhoc etc. the app installed without a problem, but the taking an image with the camera did not work.

    So I went back to debugging mode and tested the app and again the camera did not work. I updated the xam.plugin.media by upgrading the nuget package.

    I have the complile and target version to API 26 Oreo

    I keep getting this error which clicking the button to open the camera

    Java.Lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.activity.CaptureActivity clip={text/uri-list U:file:///storage/emulated/0/Android/data/carraradirectoryapp.carraradirectoryapp/files/Pictures/Sample/test.jpg} (has extras) } from ProcessRecord{7f6dc9e 32591:carraradirectoryapp.carraradirectoryapp/u0a181} (pid=32591, uid=10181) with revoked permission android.permission.CAMERA

    If I install the app for the first time when I click the button for the camera i do get asked for permission to use the camera. once i choose allow this error appears.

    I have included the CAMERA permission in the android.manifest

    Any Ideas?

  • AmirImamAmirImam USMember ✭✭
    edited February 12

    Hi,
    I have same issue now
    I am compiling my app at 8.1 Oreo
    Minimum android version: 7.1 API 25
    Xamarin.Forms: 3.5.0.129452
    With Xam.Plugin.Media 4.0.1.5, the error is : 'Method 'Plugin.CurrentActivity.ICurrentActivity.Init'
    I have added the class MainApplication and everything

    with Xam.Plugin.Media 3.1.2 the error is 'Camera permission(s) are required.' on calling
    await CrossMedia.Current.TakePhotoAsync

    Please help :(

Sign In or Register to comment.