Android: camera.getPicture() returns null while selecting image from Download folder or Google Drive
Hello,
If I try to pick image from download option (given in the left menu), getPicture() function always returns null.
However, If I navigate to file system and select any image from download folder, It works perfectly. Also, Works fine if I use DATA_URL instead of FILE_URI in destinationType.
Here is the camera options that I have set.
cameraOptions = {
quality: 100,
allowEdit: false,
correctOrientation: true,
saveToPhotoAlbum: true,
destinationType: this.camera.DestinationType.FILE_URI,
sourceType: this.camera.PictureSourceType.SAVEDPHOTOALBUM,
mediaType: this.camera.MediaType.ALLMEDIA
}
I am using: cordova - 8.0.0 cordova-plugin-camera 4.0.3 cordova-plugin-file 6.0.1 Android device version checked: 7.0, 8.0
Thanks.
Any news on this?
I can reproduce on 4.0.3, but can't reproduce with master branch (4.1.0-dev), so it got somehow fixed. Closing.
Hi @jcesarmobile ,
Thanks, i can confirm this is working with master branch (4.1.0-dev) :+1:
When this is expected to be released in stable release?
There is no date
@jcesarmobile okay thanks :)
Hi @jcesarmobile implementing further from the master branch (4.1.0-dev) seems like there is issue selecting few types of files, for ex. selecting JPEG and PNG works while MP4, PDF, XLS etc still does not work from the download folder or google drive.
Thanks
This is a camera plugin, it’s for getting pictures from gallery or camera, not for getting any type of file, there are “file picker” or “file chooser” plugins for that
I am unable to download from "cordova plugin add https://github.com/apache/cordova-plugin-camera.git".It's showing error.
Can you release 4.1.0 in NPM or Cordova?

Hi. To solve this issue replace this file -> FileHelper.java (inside ZIP) and create another support file in the same folder (FileUtils.java - inside ZIP).
See you
Hi. To solve this issue replace this file -> FileHelper.java (inside ZIP) and create another support file in the same folder (FileUtils.java - inside ZIP).
See you
@giuseeFG I tried your suggestion but while building the project again, it throws lots of error, below Logs:
BUILD FAILED in 4s cmd: Command failed with exit code 1 Error output: C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:40: error: package extras does not exist import static extras.FileUtils.generateFileName; ^ C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:40: error: static import only from classes and interfaces import static extras.FileUtils.generateFileName; ^ C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:41: error: package extras does not exist import static extras.FileUtils.getDocumentCacheDir; ^ C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:41: error: static import only from classes and interfaces import static extras.FileUtils.getDocumentCacheDir; ^ C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:42: error: package extras does not exist import static extras.FileUtils.getFileName; ^ C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:42: error: static import only from classes and interfaces import static extras.FileUtils.getFileName; ^ C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:43: error: package extras does not exist import static extras.FileUtils.saveFileFromUri; ^ C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:43: error: static import only from classes and interfaces import static extras.FileUtils.saveFileFromUri; ^ C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileUtils.java:51: error: package okhttp3 does not exist import okhttp3.ResponseBody; ^ C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileUtils.java:594: error: cannot find symbol public static File writeResponseBodyToDisk(ResponseBody body, String path) { ^ symbol: class ResponseBody location: class FileUtils C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:128: error: cannot find symbol String fileName = getFileName(context, uri); ^ symbol: method getFileName(Context,Uri) location: class FileHelper C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:129: error: cannot find symbol File cacheDir = getDocumentCacheDir(context); ^ symbol: method getDocumentCacheDir(Context) location: class FileHelper C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:130: error: cannot find symbol File file = generateFileName(fileName, cacheDir); ^ symbol: method generateFileName(String,File) location: class FileHelper C:\Users\xxxxxxx\platforms\android\app\src\main\java\org\apache\cordova\camera\FileHelper.java:134: error: cannot find symbol saveFileFromUri(context, uri, destinationPath); ^ symbol: method saveFileFromUri(Context,Uri,String) location: class FileHelper
I can reproduce on 4.0.3, but can't reproduce with master branch (4.1.0-dev), so it got somehow fixed. Closing.
I am using 4.1.0 if the file in download folder then it returns null if i moved that file to another directory then it works fine and return the file path properly