react-native-image-crop-picker: added ImagePicker.openPicker from example and the app will not start
Version
Tell us which versions you are using:
- react-native-image-crop-picker v0.39.0 but I have also tried v0.38.1
- react-native v0.71.8
Platform
I am developing on expo
Expected behaviour
I expect the app to sart and on the appropriate screen the picker to open
Actual behaviour
The app will not even start. iOs Bundling will complete, and following error will appear in the console : ERROR TypeError: Cannot read property ‘openPicker’ of null, js engine: hermes ERROR Invariant Violation: “main” has not been registered. This can happen if:
- Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
- A module failed to load due to an error and
AppRegistry.registerComponent
wasn’t called., js engine: hermes
the same happens if I just copy-paste the App.js from examples
Steps to reproduce
-
use your example
-
npm start
Attachments
My test code is very simple. I use
import ImagePicker from 'react-native-image-crop-picker';
and in my code
ImagePicker.openPicker({
width: 300,
height: 400,
cropping: true
}).then(image => {
console.log(image);
});
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 9
- Comments: 23
I had the same error. After looking at the index.js file of the node_module, it seemed the error was with the NativeModules feature of React Native.
The solution is to rebuild the app.
Can confirm part of the issue because of the cache of Metro/XCode/Android studio(Gradle)
!!! caution !!!
Make sure you did the step 3 of the installation guide. (RN > 0.71 need to do the maven path setup, RN 0.70 should have the maven path set by google() & already included the jitpack.io maven)
steps:
watchman watch-del
andwatchman watch-project
on the project path)yarn react-native start --reset-cache
ios/
folder, runpod deintegrate
andpod install
to fully reinstall all the pod then build again.npx expo start
, or'npm run start
if you have it assigned to a process in your package.json, will not start it because it doesn’t work in the metro. Instead, usenpx expo run:ios
ornpx expo run:android
, or their npm counterparts if you have them assigned to a process in the package.json file. For me they’renpm run ios
andnpm run android
. This will make the app run nativelyIt would be nice if the collaborators could work on making it accessible to the metro so that we can test it on expo go. Specially since the camera cant be accessed through a simulator
same issue, did someone found a solution ?
I got the same issue ,Cleaning the build and running pod install fixed this for me.(react native cli)