cordova-plugin-camera
cordova-plugin-camera copied to clipboard
Error "No Image Selected"
It doesn't work when I using the captured image using the camera. It always returns "No Image Selected".
Code 1
function getpic()
{
navigator.camera.getPicture(cameraCallback, onFail,
{
destinationType: Camera.DestinationType.DATA_URL
});
}
function cameraCallback(imageData)
{
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message)
{
alert('Failed because: ' + message);
}
Code 2
function getpic()
{
navigator.camera.getPicture(cameraCallback, onFail,
{
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA ,
});
}
function cameraCallback(imageData)
{
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message)
{
alert('Failed because: ' + message);
}
iOS? Android? both? OS versions?
Cannot replicate this in Android or iOS.
I'm getting the same error on iOS using the latest version of Xcode. I'm writing my project in Angular and using Ionic & Cordova to compile. This is my code:
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: this.camera.PictureSourceType.CAMERA,
allowEdit: false,
correctOrientation: true //Corrects Android orientation quirks
};
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64 (DATA_URL):
let base64Image = 'data:image/jpeg;base64,' + imageData;
console.log(base64Image);
this.launchPostPage(base64Image);
}, (err) => {
// Handle error
console.log(err);
});
}
Please were you able to find a solution
@jcesarmobile I am checked it is working if we have only one camera application. But not if many camera application. I am checked Android only.
It began working for me after I updated the package. I’m still not sure why the original issue was occurring
On Sat, Jul 20, 2019 at 11:52 AM Merbin Joe [email protected] wrote:
@jcesarmobile https://github.com/jcesarmobile I am checked it is working if we have only one camera application. But not if many camera application.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/apache/cordova-plugin-camera/issues/411?email_source=notifications&email_token=AE7BSFKJF2M2OPF6WLSEDJLQAMYEXA5CNFSM4GQJLMGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2NQ6CQ#issuecomment-513478410, or mute the thread https://github.com/notifications/unsubscribe-auth/AE7BSFKJ7LJISRTIBINLTGLQAMYEXANCNFSM4GQJLMGA .
@tbaumer22 umm, this is interesting that it works fine now. I still cannot replicate it. cc @janpio
I had the same error when getPicture was called twice. Be sure your function getpic() is called only once
"cordova-plugin-camera": "4.1.0", Android 9,10 We constantly get this error on different phones with Android 9-10 if user has several installed camera apps and he don't choose any as default, in other words - if you have choose camera app dialog you will get this error from native, so please fix it
It's not the camera app part - or maybe it's not only that - if you have allowEdit:ture in your params, and you have one or more application that can do the cropping/editing ( and have no default selected ) then you'll face the same problem
Please FIX ... thanks!
Not sure if it's relevant, but here is some lines from logcat
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: Retrieving snapshot for com.google.android.apps.camera#com.google.android.GoogleCamera failed
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: java.util.concurrent.ExecutionException: java.lang.SecurityException: GoogleCertificatesRslt: not whitelisted: pkg=com.google.android.GoogleCamera, sha1=d32102739a5ef8d9fef2faac2e3780781ea8a082, atk=false, ver=201214037.true (go/gsrlt)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at lej.a(Unknown Source:31)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at lej.a(Unknown Source:53)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at lch.a(Unknown Source:23)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at lch.a(Unknown Source:35)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at grs.c(Unknown Source:41)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at dyb.run(Unknown Source:11)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at llw.run(Unknown Source:2)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at oyj.b(Unknown Source:2)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at oxn.run(Unknown Source:22)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at oyk.run(Unknown Source:4)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at lmh.run(Unknown Source:2)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at lmg.run(Unknown Source:0)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at java.lang.Thread.run(Thread.java:919)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at lky.run(Unknown Source:5)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: Caused by: java.lang.SecurityException: GoogleCertificatesRslt: not whitelisted: pkg=com.google.android.GoogleCamera, sha1=d32102739a5ef8d9fef2faac2e3780781ea8a082, atk=false, ver=201214037.true (go/gsrlt)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at android.os.Parcel.createException(Parcel.java:2071)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at android.os.Parcel.readException(Parcel.java:2039)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at android.os.Parcel.readException(Parcel.java:1987)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at bau.b(Unknown Source:10)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at lck.a(Unknown Source:19)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at lce.a(Unknown Source:19)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at ksy.a(Unknown Source:4)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at kqw.c(Unknown Source:6)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at krw.c(Unknown Source:9)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at krw.b(Unknown Source:22)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at krw.e(Unknown Source:28)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at krw.c(Unknown Source:73)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at krw.a(Unknown Source:29)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at ktw.a(Unknown Source:119)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at kto.c(Unknown Source:90)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at ktr.handleMessage(Unknown Source:289)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at android.os.Handler.dispatchMessage(Handler.java:107)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at kzs.a(Unknown Source:0)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at kzs.dispatchMessage(Unknown Source:0)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at android.os.Looper.loop(Looper.java:214)
04-09 18:43:04.353 30804 30840 E PhenotypeFlagCommitter: at android.os.HandlerThread.run(HandlerThread.java:67)
I patched it like this: Replace line 787 of CameraLauncher.java with:
if (resultCode == 0) {
try {
destType = requestCode - CROP_CAMERA;
processResultFromCamera(destType, intent);
} catch (IOException e) {}
} else {
this.failPicture("No Image Selected");
}
The issue occurs when having multiple camera apps on your device. Tested and verified on Realme 2 pro and Pixel 3 XL (both android 10)
@jcesarmobile I am checked it is working if we have only one camera application. But not if many camera application. I am checked Android only. Workaround
The issue occurs when having multiple camera apps on your device. Tested and verified on Realme 2 pro and Pixel 3 XL (both android 10)
@jcesarmobile I am checked it is working if we have only one camera application. But not if many camera application. I am checked Android only. Workaround
Hello, I have the same problem with many camera application and no default. In my app (Ionic), in the file config.xml the preference AndroidLaunchMode was set to singleIntance, if I remove it, it work.
Sorry for bumping this, but still no solution? This is a big deal since this plugin has no real alternative and - If I'm not mistaking - this is a core plugin maintained by apache ?! So really would be nice to have this fixed - I assume a bunch of users have the same problem with it, and they don't even know because it's not that obvious ...
Confirm. If preference "AndroidLaunchMode" set to "singleInstance" in config.xml, and phone has several camera apps with no default one, then plugin will return "No Image Selected" error. But if set "AndroidLaunchMode" to "singleTask" it works.
I am trying to use cordova-plugin-camera using typescript. but when I try to call getPicture. it will open the gallery. but before that, it's going to fail method and show that no image selected.
cameraSuccess = (img: string) => { console.log(img); };
onCameraFail = (message: string) => {
console.log("Failed because: " + message);
};
onCameraClick = () => {
const options: CameraOptions = {
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
destinationType: Camera.DestinationType.DATA_URL,
};
navigator.camera.getPicture(this.cameraSuccess, this.onCameraFail, options);
};
We constantly get this error on different phones with Android 9-10 if user has several installed camera apps and he don't choose any as default, in other words - if you have choose camera app dialog you will get this error from native, so please fix it
Same for me! Zebra TC 25 (Android 7.1.2) with default camera App Snapdragon-Kamera always returned No Image Selected (I guess this is just an incompatible camera App with this Cordova Plugin), so I tried a different Camera App Open Camera which didn't work either until I selected a new default camera. So guys with multiple cameras, choose a default one!
By the way: The first time I used the new camera app, the camera selection dialog came up (Open Camera or Snapdragon Camera. Only this time or Always); I selected Open Camera as a default (Always), but at the first usage, it still didn't work in my Cordova app, because the camera selection dialog seems to break the Cordova Plugin Camera callback. It works since then.
If you have the problem No Image Selected:
- Maybe it just doesn't work with the camera app you have installed on your phone (e.g. Snapdragon) -> Try a different camera app
- When trying a different camera app, you MUST select it as default camera app.
Tested with two versions:
- cordova-plugin-camera 4.0.3 (with cordova-android 8.1.0)
- cordova-plugin-camera 5.0.0 (only worked with cordova-android 9.0.0)
It's not the camera app part - or maybe it's not only that - if you have
allowEdit:turein your params, and you have one or more application that can do the cropping/editing ( and have no default selected ) then you'll face the same problemPlease FIX ... thanks!
this worked for me.
I patched it like this: Replace line 787 of CameraLauncher.java with:
if (resultCode == 0) { try { destType = requestCode - CROP_CAMERA; processResultFromCamera(destType, intent); } catch (IOException e) {} } else { this.failPicture("No Image Selected"); }
can you please add the path.
I'm here in 2021 with the same error. Anyone have clear the status ? Exists a way to solve it ?
For the Hotfix, I just remove the edit option. but it's a bug "no select image." I need to fix it in the future.
Anyone find a fix that allows image edit / cropping?
Same problem here... No solution?
Hi I have a problem that says "No Image Selected" for Xiaomi Pocophone F1 android v10 when the user has installed a third party camera. After uninstalling the third party camera it is able to work. Are there any solutions for this?
We constantly get this error on different phones with Android 9-10 if user has several installed camera apps and he don't choose any as default, in other words - if you have choose camera app dialog you will get this error from native, so please fix it
Same for me! Zebra TC 25 (Android 7.1.2) with default camera App
Snapdragon-Kameraalways returnedNo Image Selected(I guess this is just an incompatible camera App with this Cordova Plugin), so I tried a different Camera App Open Camera which didn't work either until I selected a new default camera. So guys with multiple cameras, choose a default one!By the way: The first time I used the new camera app, the camera selection dialog came up (Open Camera or Snapdragon Camera. Only this time or Always); I selected Open Camera as a default (Always), but at the first usage, it still didn't work in my Cordova app, because the camera selection dialog seems to break the Cordova Plugin Camera callback. It works since then.
If you have the problem
No Image Selected:* Maybe it just doesn't work with the camera app you have installed on your phone (e.g. Snapdragon) -> Try a different camera app * When trying a different camera app, you MUST select it as default camera app.Tested with two versions:
* cordova-plugin-camera 4.0.3 (with cordova-android 8.1.0) * cordova-plugin-camera 5.0.0 (only worked with cordova-android 9.0.0)
Thanks to @cyril23 . We had the same problem on a Honeywell device with Android 10. We use cordova-plugin-camera 5.0.2. Cause of the problem was the incompatibility between snapdragon camera and cordova. The open camera workaround has helped us.
Thanks to @cyril23 . We had the same problem on a Honeywell device with Android 10. We use cordova-plugin-camera 5.0.2. Cause of the problem was the incompatibility between snapdragon camera and cordova. The open camera workaround has helped us.
This workaround only works until Android 11, because Android 11 does not let you select your default camera app anymore.
See https://9to5google.com/2020/08/18/android-11-default-camera-app-changes/
On an official issue tracker thread, Google confirmed (via Android Police) that Android 11 is ditching the default camera app selector. Instead of being able to download a third-party camera app from the Play Store and use that as a complete replacement, users will be stuck with whatever is pre-loaded on their device in many scenarios.
Further links:
- https://android.stackexchange.com/a/232306
- https://android.gadgethacks.com/how-to/android-11-changelog-full-list-all-50-new-features-0258964/#jump-14youcantchangethedefaultcamera
However, the Snapdragon camera worked again once we've changed our config.xml:
<preference name="AndroidLaunchMode" value="singleInstance"/>
to
<preference name="AndroidLaunchMode" value="singleTask"/>
See https://developer.android.com/guide/topics/manifest/activity-element#lmode This allowed us to continue usage of this camera plugin together with Android 11 and the Honeywell EDA52.
Same issue in 2024, on Android 8, 9 and 10 when at least two photo taking applications are installed on the device. Reproduced on emulators and various physical devices.
Seems to happen, imo, because the MEDIA_CAPTURE intent is cancelled by Android when it allow the user to chose its camera app. But the file is successfully written to the fs still.
Same issue on the cordova-plugin-media-capture plugin : https://github.com/apache/cordova-plugin-media-capture/issues/291
EDIT : I can confirm than changing the AndroidLaunchMode to singleTask fix the issue for us.