Cannot read proprety configure on null. on expo setup
Cosmin-Ciolacu opened this issue · 12 comments
Hi !! i created an app with expo and i want to run a prosses in the backgraound but it gives this error: Cannot read proprety configure on null.
Your Environment
- Plugin version: 4.2.5
- Platform: Android
- OS version: 14
- Device manufacturer / model: Emulator
- React Native version (
react-native -v
):13.6.8
Expected Behavior
i added this configuration app.json
:
{
"expo": {
"name": "mobile-app",
"plugins": ["expo-router", "react-native-background-fetch"],
"slug": "mobile-app",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "myapp",
"userInterfaceStyle": "automatic",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"ios": {
"supportsTablet": true,
"infoPlist": {
"UIBackgroundModes": ["fetch", "processing"],
"BGTaskSchedulerPermittedIdentifiers": ["com.transistorsoft.fetch"]
}
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.cosmin.App"
},
"web": {
"bundler": "metro",
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"experiments": {
"typedRoutes": true
}
}
}
then I run npx expo prebuild
and in _layout.tsx
I added this code:
const startBackgroundTask = async () => {
const onEvent = async (taskId: any) => {
console.log("Task event", taskId);
await processTask(taskId);
BackgroundFetch.finish(taskId);
};
const onTimeout = async (taskId: any) => {
console.log("Task timeout", taskId);
BackgroundFetch.finish(taskId);
};
const status = await BackgroundFetch.configure(
{
minimumFetchInterval: 15,
},
onEvent,
onTimeout
);
console.log("Background fetch status", status);
};
const processTask = async (taskId: any) => {
console.log("Processing task", taskId);
await new Promise((resolve) => setTimeout(resolve, 5000));
console.log("Task processed", taskId);
};
useEffect(() => {
startBackgroundTask();
}, []);
what I missed ?
- I don’t see the
import
statement. - How are you running your app?
- I don’t see the
import
statement.- How are you running your app?
I imported like this: import BackgroundFetch from "react-native-background-fetch";
I run the app using expo start -c
Use npx expo run:android
I run this command and it gives me this error: Project with path ':react-native-background-fetch' could not be found in project ':app'.
Re-install the plugin. Follow the install steps. You missed something.
I tried to install and make setup on a new project but, it gives me the same error.
I will put the repozitory and steps to reproduce:
pnpm i
pnpm expo prebuild
pnpm start
when it opens the app in emulator it gives me that error as warrning.
your simple "hello world" repository works for me.
after cloning:
$ npm install
$ npx expo prebuild
$ npx expo run:android
I tried on emulator,not on physical device. I will check on my phone
This issue is stale because it has been open for 30 days with no activity.