Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read proprety configure on null. on expo setup #506

Closed
Cosmin-Ciolacu opened this issue Jun 12, 2024 · 12 comments
Closed

Cannot read proprety configure on null. on expo setup #506

Cosmin-Ciolacu opened this issue Jun 12, 2024 · 12 comments
Labels

Comments

@Cosmin-Ciolacu
Copy link

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 ?

@christocracy
Copy link
Member

  • I don’t see the import statement.
  • How are you running your app?

@Cosmin-Ciolacu
Copy link
Author

  • 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

@christocracy
Copy link
Member

Use npx expo run:android

@Cosmin-Ciolacu
Copy link
Author

I run this command and it gives me this error: Project with path ':react-native-background-fetch' could not be found in project ':app'.

@christocracy
Copy link
Member

Re-install the plugin. Follow the install steps. You missed something.

@Cosmin-Ciolacu
Copy link
Author

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.

@christocracy
Copy link
Member

your simple "hello world" repository works for me.

after cloning:

$ npm install
$ npx expo prebuild
$ npx expo run:android
Screenshot 2024-06-13 at 9 34 52 AM

IMG_1264

@Cosmin-Ciolacu
Copy link
Author

I tried on emulator,not on physical device. I will check on my phone

@christocracy
Copy link
Member

Launches fine in emulator Pixel_3a_API_34_extension_level_7_arm64-v8a.

Screenshot 2024-06-13 at 9 59 06 AM

@Cosmin-Ciolacu
Copy link
Author

in my emulator it gives me this:
image
image

Also, I use windows if its problem with my OS

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jul 14, 2024
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants