react-native-background-timer icon indicating copy to clipboard operation
react-native-background-timer copied to clipboard

null is not an object (evaluating 'RNBackgroundTimer.setTimeout') - RN version 0.60.4

Open CurrieBen opened this issue 5 years ago • 5 comments

I am continually getting this error thrown and it stops the background timer from working on Android. It works no issues on iOS however.

I am not using the setTimeout function at all, I am using BackgroundTimer.setInterval if the platform is Android and using BackgroundTimer.runBackgroundTimer for iOS as even though it says it is cross platform, it only seemed to work for iOS.

React Native version: 0.60.4 React: 16.9.0 react-native-background-timer: 2.1.1

I have tried manually linking as the readme suggests, but this did not resolve the issue. Any help would be much appreciated.

passiveMode = () => {
    if (this.platform == 'ios') {
      BackgroundTimer.runBackgroundTimer(() => {
        this.main()
      }, 6000);
    } else {
      this.bgIntFunc = BackgroundTimer.setInterval(() => {
        this.main()
      }, 6000);
    }
    this.active = false
  }

As soon as the setInterval function gets called, the error is thrown and all the functionality stops for the background timer.

CurrieBen avatar Oct 08 '19 13:10 CurrieBen

Try

rm package-lock.json || true && npm i && cd ios && rm -rf Pods || true && rm Podfile.lock || true && pod install && cd ../

eyale avatar Dec 05 '19 14:12 eyale

Please run the below command:

rm -rf node_modules && yarn install && react-native link && cd android && ./gradlew clean

After running this command Open Android Studio and do these steps:

  1. delete .idea/caches(directory) .idea/modules.xml(file)
  2. delete app/build(directory)
  3. in file menu select 'Invalidate Caches / Restart'

after this let gradle sync finish and then start your server 'react-native start' and run the app. It will work.

amit13091992 avatar Jan 20 '20 06:01 amit13091992

Please run the below command:

rm -rf node_modules && yarn install && react-native link && cd android && ./gradlew clean

After running this command Open Android Studio and do these steps:

1. delete **.idea/caches**(directory)    **.idea/modules.xml**(file)

2. delete **app/build**(directory)

3. in file menu select **'Invalidate Caches / Restart'**

after this let gradle sync finish and then start your server 'react-native start' and run the app. It will work.

Didn't solve the issue for me.

tgamauf avatar Mar 08 '20 12:03 tgamauf

If you are using windows the correct command is (inside android folder) gradlew clean

not ./gradlew clean

also you need do "react-native run-android"(inside your main folder app)_ to reinstall the app with the correct dependencies

samuk190 avatar Jun 28 '20 21:06 samuk190

I'm also facing this problem although I already followed the README (manual linking included) :(

terrynguyen255 avatar Jul 08 '21 17:07 terrynguyen255