Closed cristianocca closed 6 years ago
“NativeModule Cannot be null” means your app thinks the native plugin doesn’t exist.
Work through the manual setup steps and verify everything.
It really seems like I did everything.... Is it odd that building from xcode actually fails? Although the errors are related to RN libraries and not really this.
Hmm, after doing a fresh install, and removing a library that looks like was causing errors in the link process of this one (who knows why), I'm getting a whole new set of errors:
The link command 'succeeds' but fails afterwards as follows:
ccmac:background_test cristiano$ react-native link react-native-background-fetch
Scanning folders for symlinks in /Users/cristiano/Desktop/trabajo/rn_test/background_test/node_modules (15ms)
rnpm-install info Linking react-native-background-fetch ios dependency
rnpm-install info Platform 'ios' module react-native-background-fetch has been successfully linked
rnpm-install info Linking react-native-background-fetch android dependency
rnpm-install info Platform 'android' module react-native-background-fetch has been successfully linked
path.js:28
throw new TypeError('Path must be a string. Received ' + inspect(path));
^
TypeError: Path must be a string. Received null
at assertPath (path.js:28:11)
at Object.join (path.js:1236:7)
at Object.<anonymous> (/Users/cristiano/Desktop/trabajo/rn_test/background_test/node_modules/react-native-background-fetch/scripts/postlink.js:16:23)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
/Users/cristiano/Desktop/trabajo/rn_test/background_test/node_modules/react-native/local-cli/core/makeCommand.js:32
throw new Error(`Error occurred during executing "${command}" command`);
^
Error: Error occurred during executing "node_modules/react-native-background-fetch/scripts/postlink.js" command
at ChildProcess.prelink (/Users/cristiano/Desktop/trabajo/rn_test/background_test/node_modules/react-native/local-cli/core/makeCommand.js:32:15)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
And if I open the project with XCode, the following breaks while compiling:
The JS error in the postlink.js file is because this line:
const xcodeProjectDirectory = helpers.findProject(sourceDirectory);
is null. Chances this is related to a breaking change somehwere in the lib stack?
Start from scratch with a new RN project.
Yes that's what I did.
It looks like the current combination of lib versions I'm using is broken somewhere.
It all boils down to the postlink.js error.
Harcoding the variable value like this:
// hardcode for now
const xcodeProjectDirectory = 'background_test.xcodeproj';
Gets rid of the issue, so it seems that const xcodeProjectDirectory = helpers.findProject(sourceDirectory);
is failing somewhere and returning null.
With the above "patch" and removing the library that was causing link issues, I'm able to properly run the link command and use the library without issues (at least for now)
I think there’s a bug in postlink.js.
Do not use the word “test” In your project name.
Create a new RN project without using word “test”
I see, this might explain it.
@cristianocca I am experiencing the same issue. Native module cannot be null
. Did you discover the fix for this?
It was the above, do not use test in your project name.
El 9 oct. 2018 17:52, Andrew Henderson notifications@github.com escribió:
@cristianoccahttps://github.com/cristianocca I am experiencing the same issue. Native module cannot be null. Did you discover the fix for this?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/transistorsoft/react-native-background-fetch/issues/97#issuecomment-428365720, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AILRU5-6Zb6umQqHoF1KlIO1XKFte5Gaks5ujRqNgaJpZM4VlNW-.
@cristianocca Thanks for the prompt reply. I'm not using "test" in my project name. 😐
I'm starting to think the react-native-background-fetch
isn't properly linked. I'm going to try the manual setup.
@christocracy Should TSBackgroundFetch be in the Pods > Targets? The first time I followed this tutorial, TSBackgroundFetch was present in the Targets list. The second time, it's not.
Also, what's the significance of the icon next to TSBackgroundFetch in the image below? It's the only one with that box icon. Also, does the red font mean it's not properly linked?
Following the iOS Manual Installation steps resolved the issue.
react-native -v
): 0.56.0Followed iOS manual link guide twice, double checked everything, yet trying to even import the module it's giving an error on the iOS simulator: "Native module cannot be null"
This clearly look like an error on my end while linking the module but I can't really seem what's wrong. I know this is quite difficult to troubleshoot if presented like this but perhaps it's some very obvious error: