react-native-background-fetch: App crash when background task is triggered

Your Environment

  • Plugin version: 2.7.1
  • Platform: Android
  • OS version:
  • Device manufacturer / model: Android simulator
  • React Native version (react-native -v): 0.61.5
  • Plugin config

Expected Behavior

Background task is executed successfully

Actual Behavior

App crash when background task is triggered.

Steps to Reproduce

  1. from example code, which do nothing in task

BackgroundFetch.configure({ minimumFetchInterval: 15, // Android options forceAlarmManager: false, stopOnTerminate: false, startOnBoot: true, requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY, requiresCharging: false, requiresDeviceIdle: false, requiresBatteryNotLow: false, requiresStorageNotLow: false }, async (taskId) => { // console.log(“[js] Received background-fetch event: “, taskId); BackgroundFetch.finish(taskId); }, (error) => { console.log(”[js] RNBackgroundFetch failed to start”); });

  1. Simulate a background-fetch event

adb shell cmd jobscheduler run -f <your.application.id> 999

Debug logs

Android Simulator

com.facebook.react.bridge.ReadableNativeMap cannot be cast to java.lang.Double

getDouble ReadableNativeArray.java:91

extractArgument JavaMethodWrapper.java:63

adp logcat

03-29 16:59:43.115 26718 26812 I ReactNativeJS: NotificationHandler: Mount 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: - configure: { 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “minimumFetchInterval”: 15, 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “stopOnTerminate”: false, 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “requiredNetworkType”: 1, 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “requiresBatteryNotLow”: false, 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “requiresCharging”: false, 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “requiresDeviceIdle”: false, 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “requiresStorageNotLow”: false, 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “startOnBoot”: true, 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “forceReload”: false, 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: “jobService”: “com.transistorsoft.rnbackgroundfetch.HeadlessJobService” 03-29 16:59:43.231 26718 26813 D TSBackgroundFetch: } 03-29 16:59:43.241 26718 26813 D TSBackgroundFetch: - start

// Simulate a background-fetch event //

03-29 16:59:43.439 26718 26718 I ReactNative: [GESTURE HANDLER] Initialize gesture handler for root view com.facebook.react.ReactRootView{8ee2680 V.E… …ID 0,0-1440,2620 #1} 03-29 16:59:43.492 26718 26812 I ReactNativeJS: BackgroundFetch is enabled 03-29 17:00:11.413 26718 26718 D TSBackgroundFetch: - Background Fetch event received 03-29 17:00:12.790 26718 26718 D ReactNative: CatalystInstanceImpl.destroy() start 03-29 17:00:12.791 26718 26813 I ReactNative: [GESTURE HANDLER] Tearing down gesture handler registered for root view com.facebook.react.ReactRootView{8ee2680 V.E… … 0,0-1440,2620 #1} 03-29 17:00:18.952 26718 26847 D ReactNative: CatalystInstanceImpl.destroy() end

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 22 (10 by maintainers)

Most upvoted comments

@christocracy, just to follow up I upgraded to:

“dependencies”: { “react-native”: “0.62.2”, “react-native-background-fetch”: “^3.1.0”, “react-native-background-geolocation”: “^3.7.0” … },

The issue is clearer now, it doesn’t appear to be a react-native-background-fetch issue. It’s further down the chain:

NullPointerException: Attempt to invoke interface method ‘int com.facebook.react.bridge.UIManager.addRootView(android.view.View, com.facebook.react.bridge.WritableMap, java.lang.String)’ on a null object reference

More chat on that error here: https://github.com/facebook/react-native/issues/28553

I’d ensure latest version is installed. And .gradlew clean‘

And @squalvj when you provide a “me too” response, you also need to provide all the same info as the OP:

Plugin version: Platform: OS version: Device manufacturer / model: React Native version (react-native -v): Plugin config