question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Camera.getPhoto with source "PHOTO" returns "No image picked" when choosing between multiple gallery apps

See original GitHub issue

Bug Report

Capacitor Version

Installed Dependencies:
  @capacitor/cli 1.3.0
  @capacitor/android 1.3.0
  @capacitor/ios 1.3.0
  @capacitor/core 1.3.0

Affected Platform(s)

  • Android
  • iOS
  • Electron
  • Web

Current Behavior

Error “No image picked” is returned.

Expected Behavior

The selected image should be returned

Sample Code or Sample Application Repo

Camera.getPhoto({
  source: CameraSource.Photos
});

Reproduction Steps

  1. Have multiple gallery apps installed on your device (in my case “Gallery Go by Google Photos” and “Google Photos”
  2. Trigger the getPhoto call, the OS should now show a dialog asking which app you want to use
  3. Choose an app and select a photo
  4. getPhoto resolves with the error “No image picked”

Other Technical Details

npm --version output: 6.9.0

node --version output: v12.13.0

Android version: 10 Device: Goole Pixel 3a

Other Information

I debugged into the Camera plugin, the error is returned because data is null in

public void processPickedImage(PluginCall call, Intent data) {
  if (data == null) {
    call.error("No image picked");
    return;
  }
  ...
}

So the data passed to the handleOnActivityResult method, which then calls processPickedImage, is null when Android decides to show the app selection dialog. I am not sure if it is even an issue with capacitor or if android itself is the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mrSingh007commented, Jan 20, 2020

Facing the same problem. After the image is taken from Camera there is no option to select that image. If you try to select image from Gallery then also no option to say use this image. tested on: Samsung galaxy edge 7 Cause of problem is allowEditing. When this is set to true. The image editor is opened. Now if you don’t edit your image obviously there will be no ‘Save Changes’ button. So there is only close button and this button closes the editor and also pass data is null. Workaround for us:

  • use set allowEditing to false:
const image = await Plugins.Camera.getPhoto({
      quality: 90,
      allowEditing: false,  
      resultType: CameraResultType.Uri
    });

Fix

  • The fix could be to check on handleOnActivityResult intent is from Editing and if data is null. just don’t do anything. Cause image url we have already from ‘pickImage’ intent.

@Alain1405 can you please have look on it?

1reaction
jcesarmobilecommented, Jan 16, 2020

It’s not related to the prompt, but to the app used to pick the image. Which one did you use? Device and android version are helpful too.

Also a sample app would be helpful to make sure you are not doing something wrong, I’ve just tested the “Gallery go by Google Photos” app and works fine on my device.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Camera and Image picker in Ionic 5 apps - Enappd
Learn how to pick images in Ionic 5 app using Camera and image picker. Understand the details and test on a demo android...
Read more >
Camera Capacitor Plugin API
Allows the user to pick multiple pictures from the photo gallery. On iOS 13 and older it only allows to pick one picture....
Read more >
image_picker | Flutter Package - Pub.dev
Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera.
Read more >
android - Capture Image from Camera and Display in Activity
Here's an example activity that will launch the camera app and then retrieve the image and display it. package edu.gvsu.cis.masl.camerademo; ...
Read more >
Take a picture using the camera - Flutter documentation
Many apps require working with the device's cameras to take photos and videos. ... paths to store images. path: Creates paths that work...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found