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

plugin crashes with sdk bigger than 23 - implement FileProvider

VotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      With android sdk higher than 23 I get the following error:

      E/PluginManager: Uncaught exception from plugin
      android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/at.my.namespace/cache/.Pic.jpg exposed beyond app through ClipData.Item.getUri()
      at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
      at android.net.Uri.checkFileUriExposed(Uri.java:2346)
      at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)
      at android.content.Intent.prepareToLeaveProcess(Intent.java:9530)
      at android.content.Intent.prepareToLeaveProcess(Intent.java:9515)
      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
      at android.app.Activity.startActivityForResult(Activity.java:4403)
      at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:342)
      at android.app.Activity.startActivityForResult(Activity.java:4362)
      at org.apache.cordova.CordovaInterfaceImpl.startActivityForResult(CordovaInterfaceImpl.java:66)
      at org.apache.cordova.camera.CameraLauncher.takePicture(CameraLauncher.java:294)
      at org.apache.cordova.camera.CameraLauncher.callTakePicture(CameraLauncher.java:265)
      at org.apache.cordova.camera.CameraLauncher.execute(CameraLauncher.java:174)
      at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
      at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
      at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57)
      at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
      at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
      at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:7)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:154)
      at android.os.HandlerThread.run(HandlerThread.java:61)

      It looks like Uri.fromFile has to be replaced with FileProvider.getUriForFile

      https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed

      A quick fix is to limit the sdk to version 23 in config.xml:

      <platform name="android">
      <preference name="android-minSdkVersion" value="23" />
      <preference name="android-targetSdkVersion" value="23" />

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              punknroll Joe Dalton

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment