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

[ANDROID] Application crash with FileUriExposedException trying launch intent with file URI

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: cordova-android-7.0.0
    • Fix Version/s: None
    • Component/s: cordova-android
    • Labels:
      None

      Description

      Android application crashes when there are an error and Cordova handle with it. 

      Error:  

      android.os.FileUriExposedException: file:///android_asset/www/error.html exposed beyond app through Intent.getData()

       

      Steps to reproduce: 

      1. Define preference: ErrorUrl on config.xml 
      2. Define on allow-intent:
      <allow-intent href="file://*" /> or <allow-intent href="*" />
      1. Force an error, like an invalid link, to show the error 

       

      The application will crash because of the changes introduced on Android N:

      Passing file:// URIs outside the package domain may leave the receiver with an unaccessible path. Therefore, attempts to pass a file:// URI trigger a FileUriExposedException. The recommended way to share the content of a private file is using the FileProvider.

       

      Full crash log:

      08-14 10:12:23.898 8399-8399/com.outsystems.rd.intentprovider E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.outsystems.rd.intentprovider, PID: 8399
      android.os.FileUriExposedException: file:///android_asset/www/error.html exposed beyond app through Intent.getData()
      at android.os.StrictMode.onFileUriExposed(StrictMode.java:1958)
      at android.net.Uri.checkFileUriExposed(Uri.java:2348)
      at android.content.Intent.prepareToLeaveProcess(Intent.java:9766)
      at android.content.Intent.prepareToLeaveProcess(Intent.java:9720)
      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1609)
      at android.app.Activity.startActivityForResult(Activity.java:4472)
      at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:343)
      at android.app.Activity.startActivityForResult(Activity.java:4430)
      at android.app.Activity.startActivity(Activity.java:4791)
      at android.app.Activity.startActivity(Activity.java:4759)
      at org.apache.cordova.CordovaWebViewImpl.showWebPage(CordovaWebViewImpl.java:239)
      at org.apache.cordova.CordovaActivity$2.run(CordovaActivity.java:379)
      at android.app.Activity.runOnUiThread(Activity.java:6152)
      at org.apache.cordova.CordovaActivity.onReceivedError(CordovaActivity.java:377)
      at org.apache.cordova.CordovaActivity.onMessage(CordovaActivity.java:465)
      at org.apache.cordova.CordovaActivity$1.onMessage(CordovaActivity.java:214)
      at org.apache.cordova.PluginManager.postMessage(PluginManager.java:318)
      at org.apache.cordova.CordovaWebViewImpl$EngineClient.onReceivedError(CordovaWebViewImpl.java:518)
      at org.apache.cordova.engine.SystemWebViewClient.onReceivedError(SystemWebViewClient.java:209)
      at android.webkit.WebViewClient.onReceivedError(WebViewClient.java:267)
      at com.android.webview.chromium.WebViewContentsClientAdapter.onReceivedError2(WebViewContentsClientAdapter.java:627)
      at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:7357)
      at android.os.Handler.dispatchMessage(Handler.java:105)
      at android.os.Looper.loop(Looper.java:164)
      at android.app.ActivityThread.main(ActivityThread.java:6541)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
      

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                vmfo Vitor Oliveira
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: