Rapsssito / react-native-background-actions

React Native background service library for running background tasks forever in Android & iOS.
MIT License
819 stars 117 forks source link

[Reopened Issue] TypeError: null is not an object (evaluating '_RNBackgroundActionsModule.RNBackgroundActions.start') #123

Closed jakeee51 closed 2 years ago

jakeee51 commented 2 years ago

Hey, would like to re-open this issue. Am getting this same error on this library's version 2.6.5. Please see the error logs below that I received using the example code in your repo:

[Unhandled promise rejection: TypeError: null is not an object (evaluating '_RNBackgroundActionsModule.RNBackgroundActions.start')]
at node_modules\react-native-background-actions\src\index.js:83:18 in BackgroundServer#start
at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch
at node_modules\regenerator-runtime\runtime.js:294:29 in invoke
at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch
at node_modules\regenerator-runtime\runtime.js:155:27 in invoke
at node_modules\regenerator-runtime\runtime.js:190:16 in PromiseImpl$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:45:6 in tryCallTwo
at node_modules\react-native\node_modules\promise\setimmediate\core.js:200:22 in doResolve
at node_modules\react-native\node_modules\promise\setimmediate\core.js:66:11 in Promise
at node_modules\regenerator-runtime\runtime.js:189:15 in callInvokeWithMethodAndArg
at node_modules\regenerator-runtime\runtime.js:212:38 in enqueue
at node_modules\regenerator-runtime\runtime.js:239:8 in exports.async
at node_modules\react-native-background-actions\src\index.js:77:4 in BackgroundServer#start

I've looked at issues #21 #34, and #75. Added, removed dependencies, deleted node_modules and rebuilt project to no avail. All I wana do is run a simple mobile app in the background.

Originally posted by @jakeee51 in https://github.com/Rapsssito/react-native-background-actions/issues/21#issuecomment-1043862753

jakeee51 commented 2 years ago

Figured it out. The underlying issue was that the package wasn't linking properly and taking in to account the necessary changes to the AndroidManifest.xml that this package needs to run.

The key is to run expo run:android for those of you using Expo Go. Or manually re-build your project in Android Studio. You'll have to add a local.properties file in your android directory which contains the property and value of your android sdk.dir path (i.e.: sdk.dir=C\:\\%LOCALAPPDATA%\\AppData\\Local\\Android\\Sdk ). After that you may allow your project through your antivirus and resolve a few bugs you see in the CLI after attempting to build.

JoarDev commented 2 years ago

Same issue here TypeError: null is not an object (evaluating '_RNBackgroundActionsModule.RNBackgroundActions.start') The only solution that worked for me was to run the following command from the "Using React Native < 0.60" section on the "Install" tutorial (even though i am using react native 0.63.2 which is greater than 0.60)

👉 yarn react-native link react-native-background-actions

It was definitely an autolinking problem because after that there were no errors. Before reaching that solution i also tried adding and removing the dependency, deleting node_modules folder, cleaning gradle and rebuilding the project with android studio but none of these worked for me. Hope this helps someone.