Undefined is not an object — react-native-image-picker

I was recently trying to integrate a image picker (react-native-image-picker) in to one of our React Native projects when I started running in to a issue on android where the app would crash every time we called any of the image picker functions from the JS code.

So as you usually do I checked the registered issues on GitHub to see if this was a known issue. Keep in mind that the image picker works on IOS, and does not crash during build, it only crashes when you call the .showImagePicker function.

Turns out there is 3 registered issues.


IOS, Android and both platforms.

The solution recommended by the repo maintainers for all 3 of these issues was read the docs and make sure you have imported, installed and linked everything correctly. This is all well and good but it did not solve my problem, I checked everyone 3 times over and got a team-mate to check my code as well. No problems, it all matches the documentation to a tee.

Solution! 🎉

I realise that because I am using React Native Navigation that I need to import the ImagePickerPackage() in createAdditionalReactPackages() as well as getPackages() after doing this and re-building, it all works like a charm.
See the code below for reference.