Closed arshiyanaz closed 6 months ago
If you’re having an error with the .configure method, why not post your call to .configure?
com.facebook.react.bridge.NativeArgumentsParseException: RNBackgroundFetch.configure got 2 arguments, expected 3
This is the classic "I updated the javascript code but did not rebuild the native modules to match" type crash I think. Javascript Bundle vs Native mismatch. Very occasionally caused by some dynamic bundle update system (like, codepush) dropping an old bundle unexpectedly on to new native code as a subtle variant.
It can also be be caused by a developer updating from a very old version of the plugin (from when .configure used to accept 2 Args; before the onTimeout
callback was added) without reviewing the api docs in the readme, which clearly states that 3 args are required.
This is why I want to see what args are being provided to .configure — are there 2 or 3?
BackgroundFetch.configure({
minimumFetchInterval: 30, // <-- minutes ( minimum allowed)
// Android options
forceAlarmManager: true, // <-- Set true to bypass JobScheduler.
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
// periodic:false,
requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY, // Default
requiresCharging: false, // Default
requiresDeviceIdle: false, // Default
requiresBatteryNotLow: false, // Default
requiresStorageNotLow: false // Default
}, async (taskId) => {
//console.log("[js] Received background-fetch event: ", taskId);
// Required: Signal completion of your task to native code
// If you fail to do this, the OS can terminate your app
// RealmController.addFake(realm, {})
//console.log('tac');
try {
let loginData = RealmController.getLoginData(realm, LoginSchema.name);
loginData = loginData['0'] ? loginData['0'] : {};
if (loginData.username) {
let myTasks = rootStore.myTasksModel;
myTasks.callToBackgroundGetChecklistApi();
}
} catch (error) {
//console.log("error::" + error);
}
// or assign battery-blame for consuming too much background-time
BackgroundFetch.finish(taskId);
}, (error) => {
//console.log("[js] RNBackgroundFetch failed to start");
});
How many arguments are you providing the .configure method?
3 arguments as i have shared code also above. please guide me if am wrong
It can also be be caused by a developer updating from a very old version of the plugin (from when .configure used to accept 2 Args; before the
onTimeout
callback was added) without reviewing the api docs in the readme, which clearly states that 3 args are required.This is why I want to see what args are being provided to .configure — are there 2 or 3?
yes i updated this library recently
You probably have something mucked up in your cache, as @mikehardy suggests.
I suggest you ensure you terminated / restart your dev server and clean up the other usual things
I updated the javascript code but did not rebuild the native modules to match
I updated the javascript code but did not rebuild the native modules to match- can you please explain this.itried to clean cache and gradle but still getting same error.
I suggest you remove the plugin and get your app to boot without the plugin.
then re-add it.
I am experiencing the same error as OP.
Plugin version:4.0.0 Platform: Android OS version:Android 12 Device manufacturer / model:Pixel 6 Pro API 31(emulator) React Native version (react-native -v):0.63.2 Plugin config { minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed) // Android options stopOnTerminate: false, startOnBoot: true, requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY, // Default requiresCharging: false, // Default requiresDeviceIdle: false, // Default requiresBatteryNotLow: false, // Default requiresStorageNotLow: false, // Default enableHeadless: false },
I have completely cleaned project, rebuilt several times from scratch, done all of the usual things and doesn't help.
Definitely have a 3rd argument, here is my code:
` componentDidMount() { const refreshTask = async () => { await this.update(); BackgroundFetch.finish(); }
const onTimeout = async () => {
console.log('BackgroundFetch failed to start');
BackgroundFetch.finish();
}
BackgroundFetch.configure({
minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed)
// Android options
stopOnTerminate: false,
startOnBoot: true,
requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY, // Default
requiresCharging: false, // Default
requiresDeviceIdle: false, // Default
requiresBatteryNotLow: false, // Default
requiresStorageNotLow: false, // Default
enableHeadless: false
},
refreshTask,
onTimeout
);
BackgroundFetch.status((status) => {
switch(status) {
case BackgroundFetch.STATUS_RESTRICTED:
break;
case BackgroundFetch.STATUS_DENIED:
break;
case BackgroundFetch.STATUS_AVAILABLE:
break;
}
});`
@arshiyanaz arshiyanaz were you able to fix?
I suggest you build yourself a simple hello world app and first experiment in a simple app separate from your app.
I am experiencing the same error as OP.
Plugin version:4.0.0 Platform: Android OS version:Android 12 Device manufacturer / model:Pixel 6 Pro API 31(emulator) React Native version (react-native -v):0.63.2 Plugin config { minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed) // Android options stopOnTerminate: false, startOnBoot: true, requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY, // Default requiresCharging: false, // Default requiresDeviceIdle: false, // Default requiresBatteryNotLow: false, // Default requiresStorageNotLow: false, // Default enableHeadless: false },
I have completely cleaned project, rebuilt several times from scratch, done all of the usual things and doesn't help.
Definitely have a 3rd argument, here is my code:
` componentDidMount() { const refreshTask = async () => { await this.update(); BackgroundFetch.finish(); }
const onTimeout = async () => { console.log('BackgroundFetch failed to start'); BackgroundFetch.finish(); } BackgroundFetch.configure({ minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed) // Android options stopOnTerminate: false, startOnBoot: true, requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY, // Default requiresCharging: false, // Default requiresDeviceIdle: false, // Default requiresBatteryNotLow: false, // Default requiresStorageNotLow: false, // Default enableHeadless: false }, refreshTask, onTimeout ); BackgroundFetch.status((status) => { switch(status) { case BackgroundFetch.STATUS_RESTRICTED: break; case BackgroundFetch.STATUS_DENIED: break; case BackgroundFetch.STATUS_AVAILABLE: break; } });`
@arshiyanaz arshiyanaz were you able to fix?
unfortunately no.issue still exist.
Build a simple hello world app. Verify the simplest possible implementation works.
Your Environment
- Plugin version:4.1.1
- Platform: Android
- OS version:Android 10 and above
- Device manufacturer / model:One plus
- React Native version (
react-native -v
):0.63.2- Plugin config { minimumFetchInterval: 30, // <-- minutes ( minimum allowed) // Android options forceAlarmManager: true, // <-- Set true to bypass JobScheduler. stopOnTerminate: false, startOnBoot: true, enableHeadless: true, // periodic:false, requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY, // Default requiresCharging: false, // Default requiresDeviceIdle: false, // Default requiresBatteryNotLow: false, // Default requiresStorageNotLow: false // Default },
Expected Behavior
App should not crash on start
Actual Behavior
App is crashing after splashscreen
Steps to Reproduce
Context
i was trying build apk and run it in diff devices
Debug logs
2022-12-22 00:47:13.253 13374-13374/? E/sa.smartcontro: Unknown bits set in runtime_flags: 0x28000 2022-12-22 00:47:14.199 13374-15908/ae.adafsa.smartcontrol E/unknown:ReactNative: ReactInstanceManager.createReactContext: mJSIModulePackage null 2022-12-22 00:47:14.199 13374-15921/ae.adafsa.smartcontrol E/ReactNativeJNI: logMarker CREATE_REACT_CONTEXT_END 2022-12-22 00:47:14.227 13374-15921/ae.adafsa.smartcontrol E/ReactNativeJNI: logMarker RUN_JS_BUNDLE_START 2022-12-22 00:47:14.228 13374-15922/ae.adafsa.smartcontrol E/unknown:ReactNative: ReactInstanceManager.attachRootViewToInstance() 2022-12-22 00:47:14.485 13374-15922/ae.adafsa.smartcontrol E/unknown:ReactRootView: runApplication: call AppRegistry.runApplication 2022-12-22 00:47:14.656 13374-13374/ae.adafsa.smartcontrol E/unknown:ReactNative: Unable to launch logbox because react was unable to create the root view 2022-12-22 00:47:15.681 13374-13374/ae.adafsa.smartcontrol E/libc: Access denied finding property "ro.serialno" 2022-12-22 00:47:16.551 13374-15921/ae.adafsa.smartcontrol E/ReactNativeJNI: logMarker RUN_JS_BUNDLE_END 2022-12-22 00:47:16.836 13374-15922/ae.adafsa.smartcontrol E/unknown:ReactNative: CatalystInstanceImpl caught native exception com.facebook.react.bridge.NativeArgumentsParseException: RNBackgroundFetch.configure got 2 arguments, expected 3 at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:349) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:214) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:919) 2022-12-22 00:47:16.837 13374-15922/ae.adafsa.smartcontrol E/unknown:DisabledDevSupportManager: Caught exception com.facebook.react.bridge.NativeArgumentsParseException: RNBackgroundFetch.configure got 2 arguments, expected 3 at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:349) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:214) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:919)
--------- beginning of crash
2022-12-22 00:47:16.837 13374-15922/ae.adafsa.smartcontrol E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: ae.adafsa.smartcontrol, PID: 13374 com.facebook.react.bridge.NativeArgumentsParseException: RNBackgroundFetch.configure got 2 arguments, expected 3 at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:349) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:214) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:919)
I have just had the same problem ("react-native": "0.66.3", "react-native-background-fetch": "4.1.5"). Upgraded from 3.1.0 (btw .configure call already had 3 arg).
I did next:
remove android/build
remove android/app/build
remove android/.gradle
$ android/gradlew --stop
remove
and only these actions finaly helps! Nothing helped without restarting mac.
So maybe try to restart your pc (probably mac?) or better do the same actions in the same order. Good luck!
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Your Environment
react-native -v
):0.63.2Expected Behavior
App should not crash on start
Actual Behavior
App is crashing after splashscreen
Steps to Reproduce
1. 2. 3. 4.
Context
i was trying build apk and run it in diff devices
Debug logs
2022-12-22 00:47:13.253 13374-13374/? E/sa.smartcontro: Unknown bits set in runtime_flags: 0x28000 2022-12-22 00:47:14.199 13374-15908/ae.adafsa.smartcontrol E/unknown:ReactNative: ReactInstanceManager.createReactContext: mJSIModulePackage null 2022-12-22 00:47:14.199 13374-15921/ae.adafsa.smartcontrol E/ReactNativeJNI: logMarker CREATE_REACT_CONTEXT_END 2022-12-22 00:47:14.227 13374-15921/ae.adafsa.smartcontrol E/ReactNativeJNI: logMarker RUN_JS_BUNDLE_START 2022-12-22 00:47:14.228 13374-15922/ae.adafsa.smartcontrol E/unknown:ReactNative: ReactInstanceManager.attachRootViewToInstance() 2022-12-22 00:47:14.485 13374-15922/ae.adafsa.smartcontrol E/unknown:ReactRootView: runApplication: call AppRegistry.runApplication 2022-12-22 00:47:14.656 13374-13374/ae.adafsa.smartcontrol E/unknown:ReactNative: Unable to launch logbox because react was unable to create the root view 2022-12-22 00:47:15.681 13374-13374/ae.adafsa.smartcontrol E/libc: Access denied finding property "ro.serialno" 2022-12-22 00:47:16.551 13374-15921/ae.adafsa.smartcontrol E/ReactNativeJNI: logMarker RUN_JS_BUNDLE_END 2022-12-22 00:47:16.836 13374-15922/ae.adafsa.smartcontrol E/unknown:ReactNative: CatalystInstanceImpl caught native exception com.facebook.react.bridge.NativeArgumentsParseException: RNBackgroundFetch.configure got 2 arguments, expected 3 at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:349) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:214) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:919) 2022-12-22 00:47:16.837 13374-15922/ae.adafsa.smartcontrol E/unknown:DisabledDevSupportManager: Caught exception com.facebook.react.bridge.NativeArgumentsParseException: RNBackgroundFetch.configure got 2 arguments, expected 3 at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:349) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:214) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:919) --------- beginning of crash 2022-12-22 00:47:16.837 13374-15922/ae.adafsa.smartcontrol E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: ae.adafsa.smartcontrol, PID: 13374 com.facebook.react.bridge.NativeArgumentsParseException: RNBackgroundFetch.configure got 2 arguments, expected 3 at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:349) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:214) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:919)