react-native-image-picker: ImagePicker Error: Cannot launch photo library

Bug report

Summary

Hi, I was using react-native v0.59.5 and react-native-image-picker v0.28.1 and after installing the package and running react-native link react-native-image-picker everything worked fine. Recently I created a new react-native application using react-native v0.63.0 and I installed react-native-image-picker v2.3.3. Since react-native v0.60+ everything is auto-linked. I did not run the react-native link react-native-image-picker command. So after, running the app, I was not able to get images from the library. I can click images from the camera but not able to pick images from the library. On clicking Choose from Library, I get the error ImagePicker Error: Cannot launch photo library

Environment info

react-native info output:

System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-2415M CPU @ 2.30GHz
    Memory: 388.00 MB / 12.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.1 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.6.0. - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    Android SDK:
      API Levels: 23, 26, 27, 28, 29
      Build Tools: 26.0.2, 27.0.3, 28.0.3, 29.0.2
      System Images: android-26 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6514223
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_211 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.9.0 => 16.9.0 
    react-native: 0.63.0 => 0.63.0 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 2.3.3

Steps to reproduce

  1. Create a new react-native application. Install react-native-image-picker v2.3.3

Describe what you expected to happen:

  1. I should be able to pick images from the Library.

Reproducible sample code


const options = {
    quality: 1.0,
    storageOptions: {
        skipBackup: true,
    },
};
ImagePicker.showImagePicker(options, (response) => {
    if (response.didCancel) {
        console.log('User cancelled photo picker');
    } else if (response.error) {
        console.log('ImagePicker Error: ', response.error);
    } else if (response.customButton) {
        console.log('User tapped custom button: ', response.customButton);
    } else {
        console.log('ImagePicker Response: ',response.type, response.fileName, response.uri);
    }
});

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Added the following queries section in androidManifest.xml. It fixed this issue for me.

Can you please tell what did you added in manifest to solved this?

We had this issue with Image picker package with Android 12. I added the queries section within [MANIFEST] node as follows:

` <manifest … package=“com.sampleApp” >

<queries>
    <intent>
        <action android:name="android.media.action.IMAGE_CAPTURE" />
    </intent>
    <intent>
        <action android:name="android.intent.action.GET_CONTENT" />
        <data android:mimeType="image/*" />
    </intent>
    <intent>
        <action android:name="android.intent.action.PICK" /> 
        <data android:mimeType="image/*" />
    </intent>
    <intent>
        <action android:name="android.intent.action.CHOOSER" />
    </intent>
</queries>

<application ...
</application> </manifest> `

Note: Android studio though may say - “Element queries is not allowed here” but donot worry it works like a charm 😃

@davidbiller are you importing correctly? May be also cache issue, run npx react-native start --reset-cache. Remove node_modules and reinstall. Try and ping.

@ravirajn22 Error: Unable to resolve module ./internal/nativeInterface from node_modules/react-native-image-picker/src/index.ts:

Added the following queries section in androidManifest.xml. It fixed this issue for me.

Can you please tell what did you added in manifest to solved this?

We had this issue with Image picker package with Android 12. I added the queries section within [MANIFEST] node as follows:

` <manifest … package=“com.sampleApp” >

<queries>
    <intent>
        <action android:name="android.media.action.IMAGE_CAPTURE" />
    </intent>
    <intent>
        <action android:name="android.intent.action.GET_CONTENT" />
        <data android:mimeType="image/*" />
    </intent>
    <intent>
        <action android:name="android.intent.action.PICK" /> 
        <data android:mimeType="image/*" />
    </intent>
    <intent>
        <action android:name="android.intent.action.CHOOSER" />
    </intent>
</queries>

<application ...

` Note: Android studio though may say - “Element queries is not allowed here” but donot worry it works like a charm 😃

Thanks. it’s working. Note: need update android/build.gradle at least verison 3.5.4 like this:

dependencies {
     classpath("com.android.tools.build:gradle:3.5.4")      
     ...
 }

0.63.2 same issue ,how resolve?