React-native-image-crop-picker: Cannot read property 'openPicker' of undefined

Created on 20 Mar 2017  路  29Comments  路  Source: ivpusic/react-native-image-crop-picker

Version

  • react-native-image-crop-picker v0.12.8
  • react-native v0.41.2

Platform

  • iOS

I've done all this:

Add NSPhotoLibraryUsageDescription and NSCameraUsageDescription to info.plist

npm i react-native-image-crop-picker --save
react-native link react-native-image-crop-picker

Drag and drop the ios/ImageCropPickerSDK folder to your xcode project. (Make sure Copy items if needed IS ticked)
Click on project General tab

  • Under Deployment Info set Deployment Target to 8.0
  • Under Embedded Binaries click + and add RSKImageCropper.framework and QBImagePicker.framework

But still when i'm importing

import ImagePicker from 'react-native-image-crop-picker'

ImagePicker is undefined with all the consequences. In the example code you are referring to NativeModules. This doesn't work either.

Any suggestions?

Most helpful comment

I got it to work by running the following in console:
react-native unlink react-native-image-crop-picker
react-native link react-native-image-crop-picker

All 29 comments

this means some of installation steps failed. I highly recommend to use cocoapods for external libraries. It will make your life easier. Give it a try. You can check readme for more instructions.

I am having the same issue as @anton-aleksandrov. (I'm also using [email protected]). So I took your advice and started trying cocoapods.

Unfortunately, I am not experienced iOS developer so I have been looking at this guide to try and get cocoapods to work, but have had no success so far. Do you know of any good guides for getting cocoapods to work with React Native?

Secondly can you elaborate on this point: Drag and drop the ios/ImageCropPickerSDK folder to your xcode project. (Make sure Copy items if needed IS ticked). It's not clear to me where the SDK should go in the project, also what does IS stand for here?

Thank you very much for your help, this library looks awesome, and I'd love to use it in my project.

Found this tutorial on the react native website.

I am also getting same issue in android. The react-native link react-native-image-crop-picker command could not successfully link to my android app. So i have done manual steps for linking in android such as import com.reactnative.ivpusic.imagepicker.PickerPackage in my MainApplication.java file etc.

After that i have rebuild my project the error is cleared. So kindly you have to check react-native-image-crop-picker is linked to your ios app, if not do that manual steps which are needed for ios.

@Asha-Nellaiappan, try my PR above and see if that helps.

@ivpusic same error here on android dev white integrating to the existing app. or keeps reporting undefined is not an object (evaluating '_reactNativeImageCropPicker2.default.openPicker') if using openPicker method.

The project architecture is like this:

qq 20170530105030

all the node modules are placed in RNComps folder while writing native code in android && iOS.

So is there any way to link the library?

any updates on this ? I have the same problem on iOS (not using pods)

I got it to work by running the following in console:
react-native unlink react-native-image-crop-picker
react-native link react-native-image-crop-picker

I had this problem also in iOS but like ivpusic said read the readme for instructions! There are also instruction when you don't want to use Cocoapods.

getting same issue
RN 0.46 ,
OS : windows 10

@asha-nellaiappan can you please elaborate manual steps for linking in android such as import com.reactnative.ivpusic.imagepicker.PickerPackage in my MainApplication.java file etc.

This thread is very helpful

https://github.com/ivpusic/react-native-image-crop-picker/tree/master/example , this has all the solutions , please refer to this link for setup

I got it working by doing @raynoppe steps. Thanks man!

Interestingly, I was facing the same problem with react-native run-ios however when I open the xcode project and build the app from there the problem just disappeared.

Also, I got rid of this by placing node_modules/react-native-image-crop-picker/ios/imageCropPicker.xcodeproj in my project and also adding libimageCropPicker.a to Linked Frameworks and Libraries.

Thanks! @luco its working by adding libimageCropPicker.a 馃榾

i used the cocoapods way, but get the same error. Do you need to call react-native link react-native-image-crop-picker when using cocoapods?

For iOS: CocoaPods was enough
For Android: the react-native link react-native-omage-crop-picker command missed:

import com.reactnative.ivpusic.imagepicker.PickerPackage;
...
new PickerPackage(),
...

in MainApplication.java

Cheers!

for my case, follow the tree steps fix the issue(on ios)

1.install the lib with npm
2.drag the project file imageCropPicker.xcodeproj to the Libraries
2.under the "Linked Frameworks and Libraries" click add button then choose the "libimageCropPicker.a"

just write here if someone faces the same problem can try

I had the same error.
Most of you who have _linked it properly_ is still getting the error because you _did not build the app again_.
So all you have to do is:

  • Install it:
npm install --save react-native-image-crop-picker
  • Link it to the android project by following the example project and running:
react-native link
  • Then after linking just build the app again by running -
react-native run-android
  • Then start the server again:
react-native start

This will solve your problem :smile: :+1:

Hello, I am having the same issue, undefined is not an object evaluating _reactNativeImageCropPicker2.default.openPicker
I am working only with Expo, and not doing deployments to IOS or Android.
I already tried unlink and link react-image-image-crop-picker with no luck

me too

I also encountered this error and had basically given up hope on using this library, but since there aren't any other great alternatives I persisted. I don't use cocoapods, but I installed according to the readme and was getting the "Cannot read property" error when calling the openPicker function. Turns out that calling "rm -rf node_modules/" and then "npm install" was the solution. Hope this helps someone.

I got it to work by closing Xcode and running pod install again, and then opening the workspace again

Thanks! @luco its working by adding libimageCropPicker.a 馃榾

@kantharia where is this file I can't see it?

Also, I got rid of this by placing node_modules/react-native-image-crop-picker/ios/imageCropPicker.xcodeproj in my project and also adding libimageCropPicker.a to Linked Frameworks and Libraries.

@luco what does "placing node_modules/react-native-image-crop-picker/ios/imageCropPicker.xcodeproj in my project " mean exactly? Do you copy paste that somewhere? I have not much idea about xcode and ios dev. Thanks!

I got rid of this by creating react-native-image-crop-picker folder inside node_modules and run cd ios && pod install

Was this page helpful?
0 / 5 - 0 ratings

Related issues

equesteo picture equesteo  路  3Comments

tximpa91 picture tximpa91  路  3Comments

DISKONEKTeD picture DISKONEKTeD  路  3Comments

leelandclay picture leelandclay  路  3Comments

zhangjunhou picture zhangjunhou  路  3Comments