Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-13781

Error requesting permission on Android 8 - Save on photo album issue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • None
    • cordova-plugin-camera
    • None

    Description

      Google has changed how an android application must request permissions on Android 8. In fact, it is considered as fix by Google due to a wrong behavior on previous versions.

      Related documentation:

      https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp

      This change made by Google has affected the cordova-camera-plugin. To save a photo in Photo Album, the plugin just requests the READ_EXTERNAL_STORAGE permission right now, but that is not enough on Android 8 because the plugin writes the photo file into Pictures folder so it has to request the writing permission, which is missing, as well.

      This is the error that the plugin throws when a photo is tried to be saved into the photo album on Android 8.

      > 01-12 11:38:16.757 W/System.err(22321): java.io.FileNotFoundException: open failed: EACCES (Permission denied)
      > 01-12 11:38:16.758 W/System.err(22321): at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:313)
      > 01-12 11:38:16.758 W/System.err(22321): at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:211)
      > 01-12 11:38:16.758 W/System.err(22321): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1242)
      > 01-12 11:38:16.758 W/System.err(22321): at android.content.ContentResolver.openOutputStream(ContentResolver.java:1007)
      > 01-12 11:38:16.758 W/System.err(22321): at android.content.ContentResolver.openOutputStream(ContentResolver.java:983)
      > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.camera.CameraLauncher.writeUncompressedImage(CameraLauncher.java:979)
      > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.camera.CameraLauncher.writeUncompressedImage(CameraLauncher.java:1015)
      > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:603)
      > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:919)
      > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:152)
      > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:358)
      > 01-12 11:38:16.758 W/System.err(22321): at android.app.Activity.dispatchActivityResult(Activity.java:7235)
      > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread.deliverResults(ActivityThread.java:4336)
      > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4383)
      > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread.-wrap19(Unknown Source:0)
      > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1652)
      > 01-12 11:38:16.758 W/System.err(22321): at android.os.Handler.dispatchMessage(Handler.java:105)
      > 01-12 11:38:16.758 W/System.err(22321): at android.os.Looper.loop(Looper.java:164)
      > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread.main(ActivityThread.java:6600)
      > 01-12 11:38:16.758 W/System.err(22321): at java.lang.reflect.Method.invoke(Native Method)
      > 01-12 11:38:16.758 W/System.err(22321): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
      > 01-12 11:38:16.758 W/System.err(22321): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:772)

      To sum up, if the plugin has to save a photo in the photo album, this one has to request both READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rpanadero Rubén Panadero
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: