react-native-image-crop-picker icon indicating copy to clipboard operation
react-native-image-crop-picker copied to clipboard

added ImagePicker.openPicker from example and the app will not start

Open mirco123 opened this issue 2 years ago • 28 comments

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

  1. use your example

  2. 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);
		});

IMG_5202

mirco123 avatar May 21 '23 11:05 mirco123

I can confirm this does not work in v0.40.0 either. Looks like the following code is not working anymore:

import {NativeModules} from 'react-native';

const ImageCropPicker = NativeModules.ImageCropPicker;

In my case ImageCropPicker is null

jsheffers avatar May 30 '23 16:05 jsheffers

same issue, did someone found a solution ?

Flow-Flow-Flow avatar May 31 '23 13:05 Flow-Flow-Flow

Keeping this thread alive because I'm still facing this issue

GabrielMurry avatar Jun 01 '23 18:06 GabrielMurry

me too

mirco123 avatar Jun 01 '23 20:06 mirco123

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.

  1. Close simulator and server
  2. Run npx run:ios

11arshaan avatar Jun 02 '23 23:06 11arshaan

Same error for me too. I am using the below versions

"react-native": "0.70.6", "react-native-image-crop-picker": "0.40.0",

Josh2941 avatar Jul 12 '23 19:07 Josh2941

Same error doesnt work. Gotta move on to another module :(

haiyo avatar Jul 13 '23 02:07 haiyo

Same error here. Tried to uninstall + reinstall. Tried installing pods. Tried clearing the cache. Nothing seems to work.

a-creation avatar Jul 19 '23 09:07 a-creation

I have just tried the new version [email protected] with [email protected] and [email protected] Same crash message.

mirco123 avatar Jul 20 '23 14:07 mirco123

I have just tried the new version [email protected] with [email protected] and [email protected] Same crash message.

Have you found any solution?

Xaypanya avatar Jul 29 '23 20:07 Xaypanya

0.40.0 w RN 0.70.12 works for me.

spinoza1791 avatar Aug 03 '23 21:08 spinoza1791

Hi guys, any workaround? Same error here:

[email protected] [email protected] [email protected]

arivanbastos avatar Aug 09 '23 20:08 arivanbastos

I got the same issue ,Cleaning the build and running pod install fixed this for me.(react native cli)

rajavarri avatar Sep 05 '23 07:09 rajavarri

same issue, did someone found a solution ?

thisoo avatar Sep 07 '23 03:09 thisoo

it worked for me

Android VERY IMPORTANT Add the following to your build.gradle's repositories section. (android/build.gradle) allprojects { repositories { mavenLocal() jcenter() maven { url "$rootDir/../node_modules/react-native/android" }

  // ADD THIS
  maven { url 'https://maven.google.com' }

  // ADD THIS
  maven { url "https://www.jitpack.io" }
}

} Add useSupportLibrary (android/app/build.gradle) android { ...

defaultConfig {
    ...
    vectorDrawables.useSupportLibrary = true
    ...
}
...

} Use Android SDK >= 26 (android/app/build.gradle) android { compileSdkVersion 27 buildToolsVersion "27.0.3" ...

defaultConfig {
  ...
  targetSdkVersion 27
  ...
}
...

}

LJW123 avatar Sep 22 '23 03:09 LJW123

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:

  1. run standalone metro to see if you see the watchman warning (which require you to run watchman watch-del and watchman watch-project on the project path)
  2. restart your metro and reset its cache: yarn react-native start --reset-cache
  3. if the errors insist, go to XCode/Android studio to clean the project and rebuild the binaries again.
    • XCode: if 'Clean Build Folder' isn't work for you, go to ios/ folder, run pod deintegrate and pod install to fully reinstall all the pod then build again.
    • Android Studio: if '('build' menu) Clean Project' isn't work for you, run '('build' menu) Refresh Linked C++ project' and build the project again

vincicat avatar Dec 21 '23 12:12 vincicat

Same exact issue is happening to me as well. Did all the steps in Xcode as requited per Step 3 and I get the same exact error

supermed97 avatar Jan 16 '24 15:01 supermed97

Have the same issue!!

progtarek avatar Jan 20 '24 17:01 progtarek

please help, i am also facing the same issue, im working in expo env

adityakumar0156 avatar Feb 24 '24 11:02 adityakumar0156

I have same issue but when i uninstall the app and restart the metro server my application image picker is working fine.

moin-nimblechapps avatar Mar 05 '24 09:03 moin-nimblechapps

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, use npx expo run:ios or npx expo run:android, or their npm counterparts if you have them assigned to a process in the package.json file. For me they're npm run ios and npm run android. This will make the app run natively

It 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

lotusms avatar Mar 16 '24 11:03 lotusms

  1. Stop all processes
  2. npx pod-install
  3. npm i
  4. Clear build folder/derived data folder/clear simulator
  5. npx react-native start --reset-cache
  6. npx react-native run-ios or npx react-native run-android

tungxuando avatar Mar 28 '24 09:03 tungxuando

0.40.0 w RN 0.70.12 works for me.

how? can you share

shivam27k avatar Mar 29 '24 18:03 shivam27k