Closed michaeloki closed 6 years ago
It works fine for me on the emulator...
It fails on a real device.
I have created a pull request for this fix.
Using target sdk 27 on android 8, i get this error here
07-05 09:35:05.242 4502-4502/com.foo.main W/System.err: java.io.FileNotFoundException: open failed: EACCES (Permission denied)
at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:313)
at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:211)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1248)
at android.content.ContentResolver.openOutputStream(ContentResolver.java:1013)
at android.content.ContentResolver.openOutputStream(ContentResolver.java:989)
at org.apache.cordova.camera.CameraLauncher.writeUncompressedImage(CameraLauncher.java:1076)
at org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:547)
at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:973)
at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:153)
at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:348)
at android.app.Activity.dispatchActivityResult(Activity.java:7539)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4485)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4532)
at android.app.ActivityThread.-wrap20(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1752)
07-05 09:35:05.243 4502-4502/com.foo.main W/System.err: at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Using this call:
cordovaPlugin.camera.getPicture(onGetPhotoSuccess, onGetPhotoFailed, {
correctOrientation: true,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: type,
saveToPhotoAlbum: true,
targetWidth: 2048,
targetHeight: 2048
});
When setting saveToPhotoAlbum: false
, the problem does not happen
That bug appears to be caused by this:
On android eight we don't have access to the destination file shown in the screenshot above
Use the forked version I created. This issue was reported but one of the maintainers relied on an emulator instead of testing it on a real device.
On Wed, 4 Jul 2018, 23:37 Dylan Chong, notifications@github.com wrote:
Using target sdk 27 on android 8, i get this error here
07-05 09:35:05.242 4502-4502/com.thundermaps.main W/System.err: java.io.FileNotFoundException: open failed: EACCES (Permission denied) at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:313) at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:211) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1248) at android.content.ContentResolver.openOutputStream(ContentResolver.java:1013) at android.content.ContentResolver.openOutputStream(ContentResolver.java:989) at org.apache.cordova.camera.CameraLauncher.writeUncompressedImage(CameraLauncher.java:1076) at org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:547) at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:973) at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:153) at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:348) at android.app.Activity.dispatchActivityResult(Activity.java:7539) at android.app.ActivityThread.deliverResults(ActivityThread.java:4485) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4532) at android.app.ActivityThread.-wrap20(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1752) 07-05 09:35:05.243 4502-4502/com.thundermaps.main W/System.err: at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Using this call:
cordovaPlugin.camera.getPicture(onGetPhotoSuccess, onGetPhotoFailed, { correctOrientation: true, destinationType: Camera.DestinationType.FILE_URI, sourceType: type, saveToPhotoAlbum: true, targetWidth: 2048, targetHeight: 2048 });
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/remoorejr/cordova-plugin-camera-with-exif/issues/24#issuecomment-402562628, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUdf_pzilB7KpIB_bKH-0WiY9LQzb0Fks5uDTWdgaJpZM4SFYIH .
It appears that replacing WRITE_EXTERNAL_STORAGE with READ_EXTERNAL_STORAGE inside CameraLauncher fixes the problem.
The plugin doesn't return a JSON object on Android 8.0 this prevents the app from getting the image uri and the error message in the failed callback shows that the issue is related to fileprovider i.e. file:// vs content://
See https://developer.android.com/reference/android/os/FileUriExposedException.html as a guide and permission issues.