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

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?

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 18
  • Comments: 32 (4 by maintainers)

Most upvoted comments

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

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.

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.

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!

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 😄 👍

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

This thread is very helpful

Thanks! @luco its working by adding libimageCropPicker.a 😀

getting same issue RN 0.46 , OS : windows 10