Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "No Image Selected" #411

Open
merbin2012 opened this issue Jan 16, 2019 · 28 comments
Open

Error "No Image Selected" #411

merbin2012 opened this issue Jan 16, 2019 · 28 comments

Comments

@merbin2012
Copy link

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); 
  }
@jcesarmobile
Copy link
Member

iOS? Android? both? OS versions?

@hazems
Copy link
Member

hazems commented Mar 3, 2019

Cannot replicate this in Android or iOS.

@t8
Copy link

t8 commented Apr 21, 2019

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);
    });
  }

@Samueloyeks
Copy link

Please were you able to find a solution

@merbin2012
Copy link
Author

merbin2012 commented Jul 20, 2019

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

@t8
Copy link

t8 commented Jul 20, 2019 via email

@hazems
Copy link
Member

hazems commented Jul 26, 2019

@tbaumer22 umm, this is interesting that it works fine now. I still cannot replicate it. cc @janpio

@JimmyBillan
Copy link

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

@SaintNK
Copy link

SaintNK commented Apr 9, 2020

"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

@bboldi
Copy link

bboldi commented Apr 9, 2020

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!

@bboldi
Copy link

bboldi commented Apr 9, 2020

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)

@AlibekJ
Copy link

AlibekJ commented Apr 10, 2020

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");
}

@arjued
Copy link

arjued commented Jul 23, 2020

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

@fcastell
Copy link

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.

@bboldi
Copy link

bboldi commented Aug 4, 2020

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

@Junker
Copy link

Junker commented Aug 28, 2020

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.

@thedeephakani
Copy link

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);
};

@cyril23
Copy link

cyril23 commented Oct 23, 2020

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)

@kumarichanda658
Copy link

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.

@HassanALi128
Copy link

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.

@jircdev
Copy link

jircdev commented Apr 1, 2021

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

@HassanALi128
Copy link

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.

@sjregan
Copy link

sjregan commented Sep 24, 2021

Anyone find a fix that allows image edit / cropping?

@gmbad
Copy link

gmbad commented Dec 9, 2021

Same problem here...
No solution?

@matthias1705
Copy link

matthias1705 commented Mar 8, 2022

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?

@tomuench
Copy link

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)

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.

@cyril23
Copy link

cyril23 commented May 17, 2022

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.

@bmarsaud
Copy link

bmarsaud commented Apr 15, 2024

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 : apache/cordova-plugin-media-capture#291

EDIT : I can confirm than changing the AndroidLaunchMode to singleTask fix the issue for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests