Capacitor Camera throwing "Unable to create photo on disk"
See original GitHub issueDescription of the problem: The camera plugin works great on Android 8+ devices, but for some reason, it throws the below error on a Samsung Tab A(SM-T280) Affected platform
- Android
- iOS
- electron
- web
OS of the development machine
- Windows
- macOS
- linux
Other information:
Capacitor version: 1.2.1
node version: 10.16.3
npm version: 6.11.3
Steps to reproduce:
- Configure the camera plugin as below on an Android 5 device
const image = await Plugins.Camera.getPhoto({
quality: 100,
allowEditing: false,
resultType: CameraResultType.Base64,
source: CameraSource.Camera
});
- Try opeing camera on the devices and check console for potential errors.
Logcat
10-01 12:42:20.799 20455-20642/com.uglunipart D/Capacitor/CameraUtils: Trying to save image to public external directory
10-01 12:42:50.288 20455-20642/com.uglunipart E/Capacitor/Plugin: Unable to create photo on disk
java.io.IOException: open failed: ENOENT (No such file or directory)
at java.io.File.createNewFile(File.java:944)
at java.io.File.createTempFile(File.java:1009)
at com.getcapacitor.plugin.camera.CameraUtils.createImageFile(CameraUtils.java:34)
at com.getcapacitor.plugin.Camera.openCamera(Camera.java:199)
at com.getcapacitor.plugin.Camera.showCamera(Camera.java:129)
at com.getcapacitor.plugin.Camera.doShow(Camera.java:90)
at com.getcapacitor.plugin.Camera.getPhoto(Camera.java:81)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
at com.getcapacitor.Bridge$2.run(Bridge.java:529)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at java.io.File.createNewFile(File.java:937)
at java.io.File.createTempFile(File.java:1009)
at com.getcapacitor.plugin.camera.CameraUtils.createImageFile(CameraUtils.java:34)
at com.getcapacitor.plugin.Camera.openCamera(Camera.java:199)
at com.getcapacitor.plugin.Camera.showCamera(Camera.java:129)
at com.getcapacitor.plugin.Camera.doShow(Camera.java:90)
at com.getcapacitor.plugin.Camera.getPhoto(Camera.java:81)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
at com.getcapacitor.Bridge$2.run(Bridge.java:529)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.os.HandlerThread.run(HandlerThread.java:61)
10-01 12:42:50.288 20455-20642/com.uglunipart D/Capacitor: Sending plugin error: {"save":false,"callbackId":"22237336","pluginId":"Camera","methodName":"getPhoto","success":false,"error":{"message":"Unable to create photo on disk"}}
10-01 12:42:50.308 20455-20455/com.uglunipart E/Capacitor/Console: File: http://localhost/main-es2015.a5ca47b02acd21cd4cd6.js - Line 1 - Msg: ERROR Error: Uncaught (in promise): Object: {"message":"Unable to create photo on disk"}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Capacitor Camera throwing "Unable to create photo on disk ...
The issue is caused because the directory is not created. The fix to this is to add storageDir.mkdirs(); after this code in the...
Read more >Cant "Use Photo" with Capacitor Camera Plugin - Ionic Forum
Hey! I want to implement a simple camera feature. The user should be able to take a photo, which is then passed on...
Read more >Camera | Capacitor Documentation
The Camera API allows a user to pick a photo from their photo album or take a picture. On iOS, this uses UIImagePickerController...
Read more >Creating Camera App With IONIC 4 and Capacitor Tutorial
In this video, i will show you how to build mobile app with camera functionality. Using Capacitor.Donate to help the channel: ...
Read more >How to Build a Capacitor Plugin for Camera Preview
We can use it to create cross-platform iOS, Android, and Progressive Web Apps with JavaScript, HTML, and CSS. Using Capacitor plugins, we can ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Error still continues in the latest versions, any update?
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.