Android 6 Camera/Image write problem

Been working on an app that uses the camera to create an image.  If I use an older Corona build (2769) where it requests the permissions up front, everything is OK, the image is taken and can be rendered in the app.

Using a current daily build (2838) where it asks for permissions on the fly, I allow it permission to access the files, then access the camera, take the picture but then no image in the app.  Error from Android Monitor is:

java.io.FileNotFoundException: /storage/emulated/0/Pictures/Picture32.jpg: open failed: EACCES (Permission denied)

Build.settings has the following permissions:

“android.permission.CAMERA”,

“android.permission.WRITE_EXTERNAL_STORAGE”,

The code simply uses:

 media.capturePhoto(

{

    listener=onDidSelectPhoto

})

Then the image is returned as a display object (however not in this case!).

I’m assuming its missing the storage permission.  Any ideas what I have missed or am doing incorrectly?  

Also getting exactly the same issue when using the camera sample app, Corona debug message from that is:

media.capturePhoto() returned an image!

event.target: { “path”: { “x1”: 0, “y1”: 0, “x2”: 0, “y2”: 0, “x3”: 0, “y3”: 0, “x4”: 0, “y4”: 0, “width”: 0, “height”: 0 }, “fill”: { “x”: 0, “y”: 0, “scaleX”: 1, “scaleY”: 1, “rotation”: 0 }, “stroke”: “nil”, “blendMode”: “normal”, “strokeWidth”: 0, “innerstrokeWidth”: 0, “xScale”: 1, “yScale”: 1, “rotation”: 0, “width”: 0, “height”: 0, “isVisible”: “true”, “isHitTestable”: “false”, “alpha”: 1, “x”: 0, “y”: 0, “anchorX”: 0.5, “anchorY”: 0.5, “contentBounds”: { “xMin”: 0, “xMax”: 0, “yMax”: 0, “yMin”: 0 }, “contentWidth”: 0, “contentHeight”: 0, “maskX”: 0, “maskY”: 0, “maskScaleX”: 0, “maskScaleY”: 0, “maskRotation”: 0, “isHitTestMasked”: “false” }

and Android:

java.io.FileNotFoundException: /storage/emulated/0/Pictures/Picture38.jpg: open failed: EACCES (Permission denied)

I have also noticed, if you install the app (sideload) then this happens the first time around, but if you install it again (same build installed over existing version) then it works as it should the second time around.    

If I print out the granted permissions in the listener, they are all correct too??:

03-11 13:58:22.025: I/Corona(15139): PERMISSION: android.permission.INTERNET

03-11 13:58:22.025: I/Corona(15139): PERMISSION: android.permission.WRITE_EXTERNAL_STORAGE

03-11 13:58:22.025: I/Corona(15139): PERMISSION: android.permission.CAMERA

03-11 13:58:22.025: I/Corona(15139): PERMISSION: android.permission.READ_EXTERNAL_STORAGE

Hi phil.s,

In the latest release, we announced support for Android 6, and the new runtime permission model that comes with it. Please take a look at the new Camera sample, as you have to ensure you have permission to write to external storage before you can do so.

The camera sample I built was from the latest daily build as I mentioned previously if this worked I’d be using it as a reference but it shows the same problems as the app I am working on!

Also getting exactly the same issue when using the camera sample app, Corona debug message from that is:

media.capturePhoto() returned an image!

event.target: { “path”: { “x1”: 0, “y1”: 0, “x2”: 0, “y2”: 0, “x3”: 0, “y3”: 0, “x4”: 0, “y4”: 0, “width”: 0, “height”: 0 }, “fill”: { “x”: 0, “y”: 0, “scaleX”: 1, “scaleY”: 1, “rotation”: 0 }, “stroke”: “nil”, “blendMode”: “normal”, “strokeWidth”: 0, “innerstrokeWidth”: 0, “xScale”: 1, “yScale”: 1, “rotation”: 0, “width”: 0, “height”: 0, “isVisible”: “true”, “isHitTestable”: “false”, “alpha”: 1, “x”: 0, “y”: 0, “anchorX”: 0.5, “anchorY”: 0.5, “contentBounds”: { “xMin”: 0, “xMax”: 0, “yMax”: 0, “yMin”: 0 }, “contentWidth”: 0, “contentHeight”: 0, “maskX”: 0, “maskY”: 0, “maskScaleX”: 0, “maskScaleY”: 0, “maskRotation”: 0, “isHitTestMasked”: “false” }

and Android:

java.io.FileNotFoundException: /storage/emulated/0/Pictures/Picture38.jpg: open failed: EACCES (Permission denied)

I have also noticed, if you install the app (sideload) then this happens the first time around, but if you install it again (same build installed over existing version) then it works as it should the second time around.    

If I print out the granted permissions in the listener, they are all correct too??:

03-11 13:58:22.025: I/Corona(15139): PERMISSION: android.permission.INTERNET

03-11 13:58:22.025: I/Corona(15139): PERMISSION: android.permission.WRITE_EXTERNAL_STORAGE

03-11 13:58:22.025: I/Corona(15139): PERMISSION: android.permission.CAMERA

03-11 13:58:22.025: I/Corona(15139): PERMISSION: android.permission.READ_EXTERNAL_STORAGE

Hi phil.s,

In the latest release, we announced support for Android 6, and the new runtime permission model that comes with it. Please take a look at the new Camera sample, as you have to ensure you have permission to write to external storage before you can do so.

The camera sample I built was from the latest daily build as I mentioned previously if this worked I’d be using it as a reference but it shows the same problems as the app I am working on!