Bare Workflow: Updates.reloadAsync() makes my android app crash

See original GitHub issue

Hey guys, I used to work on ExpoKit and i’ve just switch to Bare Workflow with the new release (SDK 37). Everything is working fine except for the OTA update. I’m using the manual update for my application by calling the checkForUpdateAsync and the fetchUpdateAsync methods.

Those two methods are working (the update is fetched) but when i’m trying to reload my app after this with reloadAsync method my android app crashed with a strange error (on release).

Yet, when I’m restarting the application, the update is available.

This log is extracted from adb logcat --buffer=crash:

04-08 14:30:35.158 29276 29598 E AndroidRuntime: FATAL EXCEPTION: create_react_context 04-08 14:30:35.158 29276 29598 E AndroidRuntime: Process: XXXXX, PID: 29276 04-08 14:30:35.158 29276 29598 E AndroidRuntime: com.facebook.jni.CppException: facebook::react::Recoverable: Could not open file/data/user/0/XXXX/files/.expo-internal/7C6DA04432421D9566434203858FEC7C132FA97C43BD314556629A1673F750F6.js: No such file or directory 04-08 14:30:35.158 29276 29598 E AndroidRuntime: at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromFile(Native Method) 04-08 14:30:35.158 29276 29598 E AndroidRuntime: at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromFile(Unknown Source:2) 04-08 14:30:35.158 29276 29598 E AndroidRuntime: at com.facebook.react.bridge.JSBundleLoader$2.loadScript(Unknown Source:6) 04-08 14:30:35.158 29276 29598 E AndroidRuntime: at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(Unknown Source:18) 04-08 14:30:35.158 29276 29598 E AndroidRuntime: at com.facebook.react.s.a(Unknown Source:154) 04-08 14:30:35.158 29276 29598 E AndroidRuntime: at com.facebook.react.s.a(Unknown Source:0) 04-08 14:30:35.158 29276 29598 E AndroidRuntime: at com.facebook.react.s$e.run(Unknown Source:68) 04-08 14:30:35.158 29276 29598 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
baronchngcommented, Jun 24, 2020

Hey @axelmarciano, I just recently faced and solved this issue. From your code, I think it’s better you do await Updates.reloadAsync(); so that you have control of what happens when the Promise is resolved. I don’t know where you use the hook but i will just make assumptions.

Most importantly, you shouldn’t run any code after Updates.reloadAsync() such as setState() despite the documentation said it’s not recommended when actually it seems like we cannot. Refer to Updates.reloadAsync() section in Expo Updates Doc.

Another thing to watch out is if reloadAsync() is used in App() component where normally there are a few useEffect() around, ensure that no other useEffect() will actually do something after you call reloadAsync().

What happened to me was

try {
  ... check for updates and fetch

  await Updates.reloadAsync(); <---- we shouldn't do anything after this. 
}
catch (error) {
}
finally {
  setState(); <---- this happens right after the reloadAsync() above and crashes the Android app
}

So I changed to something like

try {
  const update = await Updates.checkForUpdateAsync();
  if (update.isAvailable) {
    await Updates.reloadAsync(); 

    // don't do anything
  } else {
    setState(); <---- since the reload above will make update.isAvailable to false, this will run
  }
}
catch (error) {
}
4reactions
changLiuUNSWcommented, Apr 14, 2020

Have the same issue. reloadAsync make app crash

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expo update: reloadAsync crashes app in release build
I want to restart my react native app when I change the language of my app, Its an expo managed app with mobx...
Read more >
Updates - Expo Documentation
The expo-updates library allows you to programmatically control and respond to new updates made available to your app. Platform Compatibility. Android Device ...
Read more >
Yearly - Expo Forums
Topic Replies Views Activity Experience ID from pushToken ? Expo SDK 1 59 December 4, 2021 Older SDK Documentation · Expo SDK 2 35 June...
Read more >
Crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >
expo-updates - npm
In this workflow, release builds of both iOS and Android apps will create and embed a new update at build-time from the JS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found