Open LukeTim opened 8 years ago
I ran into this as well. As a sanity check, I outputted the RNGeocoder object just before I made the function call, to verify that the object is properly being imported and exists from the perspective of the calling script. I'm on RN 22.2 e.g.
my code (debugLog is a wrapper for console.log):
debugLog('Geocoder object',Geocoder);
Geocoder.geocodeAddress(query).then((data) => {
... stuff ...
}).catch((e) => {
debugLog('Geocoder error',e);
})
the console logging output:
Geocoder error: Cannot read property 'geocodeAddress' of undefined(…)
Geocoder object: Object {}
geocodeAddress: geocodeAddress(address,callback)
reverseGeocodeLocation: reverseGeocodeLocation(location,callback)
What I did to fix was update my copy of the RNGeocoder library, upgrading to the latest. Then (since we previously had 0.2 installed), in xCode, I re-ran the iOS setup steps to add/link the latest RNGeocoder.xcodeproj
and libRNGeocoder.a
files. I also had to delete the old one (I think it was named something like RNGeocoderSample.) When I did a new build, it worked and the error was gone.
as @juellez said this error means the JS and obj-c files are out of sync. Usually cleaning the build and recompiling the project fix this.
You can also uninstall and reinstall the lib. using rnpm
is quite easy and super fast to do
I'm running into the same issue as well.
Went through the process of removing the package from node_modules directory, then reinstalled, and added into the xcode project... Same issue.
Any next steps you can think of?
clean and rebuild didn't help, running react-native link
fixed it
I've tried it with both manually (as on README) and react-native link
(former rnpm link
) command. Worths mention that I'm trying to use it for the first time in my project and I'm getting the same issue, so I guess it's not an update issue.
I've noticed something weird, though: When navigating through the project tree inside xCode, the file libRNGeocoder.a (located at Libraries/RNGeocoder.xcodeproj/Products) appears in red, and if I try to locate that file (right clicking on it -> Show in Finder), it gets nowhere, as if the file doesn't exist.
Any ideas? Thanks! =)
It looks like RNGeocoder
is not being included in NativeModules
for some reason.
The following line returns undefined
:
const { RNGeocoder } = NativeModules;
console.log(RNGeocoder); // => undefined
https://github.com/devfd/react-native-geocoder/blob/master/js/geocoder.js#L4
I'm facing the same issue, does anybody can solve it?
@rknell react-native link fixed it 👍 but I have to run and build it again
Facing the same issue, who could help here
Geocoder.geocodeAddress(city).then(response => { console.log('response', response); });
still broken
still....
yep still
still broken...
I am hitting an error inside the geocodeAddress function in geocoder.js.
I have performed all the necessary steps to add the library to the linker. I have these lines at the top of my index.ios.js file to test:
I am seeing this error as soon as I load up the app in the simulator:
undefined is not an object (evaulating RNGeocoder.geocodeAddress)
The issue is on line 29 in geocoder.js:
return RNGeocoder.geocodeAddress(address).catch(err => {
I am guessing that RNGeocoder is for some reason undefined. Is there something I am missing? I have installed the npm module, added the libRNGeocoder.a library to the XCode linker...
I tried adding debugging code into geocoder.js but that seemed to just produce a different error; as though the Geocoder module was no longer able to be loaded.