Reputation: 11
I have got the error "Unable to create bitmap" when I try to get one image from the gallery in android. I have seen the log and I have found this error: /CameraLauncher(16616): File locaton is: /storage/emulated/0/WhatsApp/Media/WhatsApp Images/IMG-20160303-WA0002.jpg W/System.err(16616): java.io.FileNotFoundException: No such file or directory
I believe that the error is generated by the whitespace.
I am usign cordova cli 6.0 and this is my code:
var options = {
destinationType: Camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.SAVEDPHOTOALBUM,
quality: 30,
targetWidth: 300,
targetHeight: 300
};
var q = $q.defer();
navigator.camera.getPicture(function (result) {
// Do any magic you need
q.resolve(result);
}, function (err) {
q.reject(err);
}, options);
return q.promise;
How can I fix this error?
Thank you!
Upvotes: 1
Views: 1484
Reputation: 369
This is an old post, but I'll answer it anyway.
I had a similar problem, but for me the error occurred after GetPicture when trying to save the actual image. As you suspected, it's the space in "WhatsApp Images" that causes the problem, so I'm replacing the space with '%20'. URI encode might be a better option. See .replace on the 3rd line below
$cordovaCamera.getPicture(options).then(function (imageUrl) {
if (ionic.Platform.isAndroid()) {
imageUrl = imageUrl.replace(" ", "%20");
AppFileService.storeWallImage(imageUrl);
resolve({
img: imageUrl
});
});
Upvotes: 1