expo-updates: You cannot use the Updates module in development mode in a production app

762 Views Asked by At

I'm trying to update expo sdk from 46 to 49 and when I update all the packages I faced a problem related to expo-updates package

in the application I'm using RTL with a default language ar so I need to reload application if RTL is false for the first time or when user change the language.

the problem is when running the application on Expo Go for the first time this error appears

WARN  [Error: You cannot use the Updates module in development mode in a production app. To test manual updates, publish your project using `expo publish` and open the published version in this development client.]

and when I try to generate a standalone app with the eas command the application crushes or gets stuck in the splash screen.

here's the the part were i reload the application

const loadI18n = async () => {
      const lang: string | null = await localStorage.getValue("lang");
      const selectedLanguage: LanguageModel = env.languages.find((x: LanguageModel) => x.lang === ((lang !== null) ? lang : env.defaultLanguage));

      if (lang === null) {
        localStorage.save("lang", env.defaultLanguage);
      } else {
        console.log("a language is already selected, The language: ", lang)
      }
      i18n.init()
        .then(async () => {
          console.log("==============> I18nManager.isRTL: ", I18nManager.isRTL)
          const RNDir = selectedLanguage.layout;
          console.log("isRTL: ", RNDir);
          console.log("current language is :", i18next.language, "i18n.dir: ", i18n.dir);
          if ((i18n.dir !== RNDir) || (!I18nManager.isRTL && selectedLanguage.layout === 'RTL')) {
            console.log("isRTL: ", RNDir);
            console.log("current language is :", i18next.language, "i18n.dir: ", i18n.dir);
            const isLocaleRTL = selectedLanguage.layout === 'RTL';
            I18nManager.forceRTL(isLocaleRTL);
            I18nManager.allowRTL(isLocaleRTL);
            console.log("isLocaleRTL: ", selectedLanguage.layout === 'RTL');
            await Updates.reloadAsync();
          }
          setIsI18nInitialized(true);
        })
        .catch((error: any) => console.warn(error));
    }

and here's the eas file:

{
  "cli": {
    "version": ">= 3.5.2"
  },
  "build": {
    "qaMA": {
      "android": {
        "gradleCommand": ":app:assembleRelease"
      },
      "releaseChannel": "qa",
      "env": {
        "APP_COUNTRY": "MA"
      }
    },
  },
  "submit": {
    "production": {}
  }
}

command I built with eas build -p android --profile qaMA

2

There are 2 best solutions below

1
On

Same situation. i was ugraded expo SDK 44 to 49. with same language library.

0
On

Part of your problem is in the await Updates.reloadAsync(); command. This is intended for the Expo Updates mechanic but used to be applied creatively as a means to reset the app in other situations. Sadly, the way the Updates feature works has changed and this command can no longer be used in a DEV build.

This method cannot be used in development mode, and the returned promise will be rejected if you try to do so.

https://docs.expo.dev/versions/latest/sdk/updates/#updatesreloadasync