cordova-plugin-camera: 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); 
  }

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 6
  • Comments: 28 (3 by maintainers)

Most upvoted comments

I’m here in 2021 with the same error. Anyone have clear the status ? Exists a way to solve it ?

“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

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:

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.

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!

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!

this worked for me.

I had the same error when getPicture was called twice. Be sure your function getpic() is called only once

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.

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.

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)

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

@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.

Cannot replicate this in Android or iOS.