Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
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
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" />