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

OTA updates cause Android (only) to crash on startup; requires new published release to resolve #11814

Closed
alexhouse opened this issue Feb 2, 2021 · 19 comments

Comments

@alexhouse
Copy link

alexhouse commented Feb 2, 2021

Summary

I've set up and have had OTA updates running perfectly fine on previous SDK versions, but it seems to be around SDK 40 that OTA updates on Android just crash on every startup. In order to resolve this I have to publish a full new version on the Android store, which somewhat defeats the purpose of OTA updates.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

40.0.1

Environment

  Expo CLI 4.1.6 environment info:
    System:
      OS: macOS 11.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 12.20.1 - ~/.nvm/versions/node/v12.20.1/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 6.14.10 - ~/.nvm/versions/node/v12.20.1/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    IDEs:
      Xcode: 12.3/12C33 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^40.0.0 => 40.0.1
      react: 16.13.1 => 16.13.1
      react-dom: 16.13.1 => 16.13.1
      react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2
      react-native-web: ~0.13.12 => 0.13.18
    npmGlobalPackages:
      expo-cli: 4.1.6
    Expo Workflow: managed
> yarn list expo-updates
yarn list v1.22.10
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ expo-updates@0.4.1

Reproducible demo or steps to reproduce from a blank project

Actual error provided via adb logcat on a device with the published app installed following an update & restart:

Immediately following update:

02-02 11:27:20.522  9588 12805 E ReactNativeJS: Error: Expo native runtime is not available: something went wrong and we aren't sure what it was. Please post more information and get support at https://forums.expo.io.
02-02 11:27:20.529  9588 12805 E ReactNativeJS: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
--------- switch to system
02-02 11:27:20.540  1545  3275 W NetworkPolicy: shared quota unsupported; generating rule for each iface
--------- switch to main
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: CatalystInstanceImpl caught native exception
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: com.facebook.react.common.JavascriptException: Error: Expo native runtime is not available: something went wrong and we aren't sure what it was. Please post more information and get support at https://forums.expo.io., stack:
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: <unknown>@13:184
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: v@2:1473
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: <unknown>@9:66
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: v@2:1473
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: <unknown>@8:7183
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: v@2:1473
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: <unknown>@6:45
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: v@2:1473
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: d@2:875
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: global code@3742:3
02-02 11:27:20.551  9588 12806 E unknown:ReactNative:
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:83)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at java.lang.reflect.Method.invoke(Native Method)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at android.os.Handler.handleCallback(Handler.java:938)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at android.os.Looper.loop(Looper.java:223)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
02-02 11:27:20.551  9588 12806 E unknown:ReactNative: 	at java.lang.Thread.run(Thread.java:923)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: Caught exception
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: com.facebook.react.common.JavascriptException: Error: Expo native runtime is not available: something went wrong and we aren't sure what it was. Please post more information and get support at https://forums.expo.io., stack:
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: <unknown>@13:184
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: v@2:1473
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: <unknown>@9:66
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: v@2:1473
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: <unknown>@8:7183
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: v@2:1473
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: <unknown>@6:45
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: v@2:1473
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: d@2:875
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: global code@3742:3
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager:
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:83)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at java.lang.reflect.Method.invoke(Native Method)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at android.os.Handler.handleCallback(Handler.java:938)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at android.os.Looper.loop(Looper.java:223)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
02-02 11:27:20.551  9588 12806 E unknown:DisabledDevSupportManager: 	at java.lang.Thread.run(Thread.java:923)
--------- switch to crash
02-02 11:27:20.551  9588 12806 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
02-02 11:27:20.551  9588 12806 E AndroidRuntime: Process: {app_id}, PID: 9588
02-02 11:27:20.551  9588 12806 E AndroidRuntime: com.facebook.react.common.JavascriptException: Error: Expo native runtime is not available: something went wrong and we aren't sure what it was. Please post more information and get support at https://forums.expo.io., stack:
02-02 11:27:20.551  9588 12806 E AndroidRuntime: <unknown>@13:184
02-02 11:27:20.551  9588 12806 E AndroidRuntime: v@2:1473
02-02 11:27:20.551  9588 12806 E AndroidRuntime: <unknown>@9:66
02-02 11:27:20.551  9588 12806 E AndroidRuntime: v@2:1473
02-02 11:27:20.551  9588 12806 E AndroidRuntime: <unknown>@8:7183
02-02 11:27:20.551  9588 12806 E AndroidRuntime: v@2:1473
02-02 11:27:20.551  9588 12806 E AndroidRuntime: <unknown>@6:45
02-02 11:27:20.551  9588 12806 E AndroidRuntime: v@2:1473
02-02 11:27:20.551  9588 12806 E AndroidRuntime: d@2:875
02-02 11:27:20.551  9588 12806 E AndroidRuntime: global code@3742:3
02-02 11:27:20.551  9588 12806 E AndroidRuntime:
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:83)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:938)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:223)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
02-02 11:27:20.551  9588 12806 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:923)

iOS appears unaffected - published updates download & restart with no problem.

Update triggered in code by a button press:

    await Updates.fetchUpdateAsync();
    await Updates.reloadAsync();

Last Android build using EAS Jan 31, 2021 7:57 PM

@alexhouse alexhouse added the needs validation Issue needs to be validated label Feb 2, 2021
@cruzach cruzach added needs repro and removed needs validation Issue needs to be validated labels Feb 2, 2021
@cruzach
Copy link
Contributor

cruzach commented Feb 2, 2021

Hi! We require a minimal reproducible demo to be provided in each bug report so that we can quickly and efficiently investigate issues. It looks like you've left out the repro , so this is unlikely to get very much attention

@alexhouse
Copy link
Author

@cruzach Will see what I can do to reproduce, but as it seems to only occur on an app-store released app I wasn't sure if it would be possible to demo sufficiently. I'll have another look.

@kfernandes29
Copy link

I have the same issue on iOS. Can't figure out what the issue is here, its very frustrating.

@brentvatne
Copy link
Member

brentvatne commented Mar 5, 2021

@kfernandes29 - this is not a problem that is occurring on expo's end. run expo diagnostics and share the output here.

@alexhouse - you can do expo build:android -t apk --release-channel testing-updates and then expo publish --release-channel testing-updates and share that apk with us. it would be no different than deploying it to the play store. i'm curious to see how you might've encountered that error message you shared - it should only throw if expo-constants isn't available, and that is always available in managed apps:

if (shouldThrowAnErrorOutsideOfExpo() && (!Constants || !Constants.expoVersion)) {
throw new Error(
`Expo native runtime is not available: something went wrong and we aren't sure what it was. Please post more information and get support at https://forums.expo.io.`
);
}

@kfernandes29
Copy link

kfernandes29 commented Mar 5, 2021

@kfernandes29 - this is not a problem that is occurring on expo's end. run expo diagnostics and share the output here.

@alexhouse - you can do expo build:android -t apk --release-channel testing-updates and then expo publish --release-channel testing-updates and share that apk with us. it would be no different than deploying it to the play store. i'm curious to see how you might've encountered that error message you shared - it should only throw if expo-constants isn't available, and that is always available in managed apps:

if (shouldThrowAnErrorOutsideOfExpo() && (!Constants || !Constants.expoVersion)) {
throw new Error(
`Expo native runtime is not available: something went wrong and we aren't sure what it was. Please post more information and get support at https://forums.expo.io.`
);
}

Expo CLI 4.2.1 environment info:
System:
OS: macOS 11.1
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.5.0 - ~/.nvm/versions/node/v14.5.0/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.5.4 - ~/.nvm/versions/node/v14.5.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.7042882
Xcode: 12.4/12D4e - /usr/bin/xcodebuild
npmPackages:
expo: ^40.0.0 => 40.0.1
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: 0.63.4 => 0.63.4
react-native-web: ~0.13.12 => 0.13.18
npmGlobalPackages:
expo-cli: 4.2.1
Expo Workflow: bare

@brentvatne
Copy link
Member

@kfernandes29 - are you building your app with expo build:ios?

@kfernandes29
Copy link

I'm using Xcode to build it with my Staging schema.

@brentvatne
Copy link
Member

can you share the details of the crash report that you are seeing?

@kfernandes29
Copy link

Unhandled JS Exception: Error: Cannot use t "__Schema" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.

@kfernandes29
Copy link

kfernandes29 commented Mar 5, 2021

I think the issue is that my Xcode build is being created as Production, where as my OTA update with expo publish is being built as development?

@brentvatne
Copy link
Member

brentvatne commented Mar 5, 2021

expo publish produces a "production" bundle, but i don't know if you have your own way of specifying what that means and maybe that's different? either way this looks like something that has been answered on amplify-js related threads, and it is unrelated to expo

it looks like it's caused by graphql-js expecting to be run on a server environment where NODE_ENV is always set, you can workaround (i think) by running NODE_ENV=production expo publish

@kfernandes29
Copy link

Yea, I'm looking into this response here. I'll give it a shot and let you know the result.

apollographql/apollo-client#7446 (comment)

@kfernandes29
Copy link

kfernandes29 commented Mar 5, 2021

So I have great news! I installed these 2 packages in my project:

yarn add babel-plugin-transform-inline-environment-variables react-native-dotenv

I was then able to set NODE_ENV=production in my .env file and do an 'expo publish'

OTA Updates are working perfectly now!

@DavidUnzue
Copy link

Hi! We are having the same issue as originally described by @alexhouse. It happens only on Android and as soon as the app tries to fetch new OTA updates. Our setup is exactly the same. OTA Updates were working before SDK 40.

We tried setting NODE_ENV to production but that did not have any effect, the app still crashes. Honestly that doesn't seem to be the issue here and @kfernandes29 seems to have different problem.

Providing a reproducible demo here is almost impossible, as this happens only in the production app, once released. Building an apk and sharing it is also something we would like to avoid.

@bradvatne @cruzach Are there any news on this issue or any hints on how to approach it?

Thanks in advance

@alexhouse
Copy link
Author

I believe this is almost resolved in EAS now by using --target bare when running expo publish. It's still not perfect, but it no longer crashes the app immediately on launch so that's a plus...

I imagine this broke as a result of the work on EAS update

@brentvatne
Copy link
Member

ah yes - when we officially release managed app preview support on eas build this will be resolved. it's fixed for sdk 41 already - we removed the concept of publish targets entirely. we documented this here

@DavidUnzue
Copy link

@alexhouse @brentvatne Thank you for the quick responses.

Actually, we aren't using EAS at all. To build the Android binary (apk file), we do expo eject and build the app ourselves using Android Studio. This is because we want to make little modifications to the native code to secure against tapjacking attacks.

For OTA updates, we simply use expo-updates and the expo publish command from an Expo managed workflow. No EAS here either.

Might the issue be related to the fact that the Android build receiving the OTA update was created from a bare workflow?

@brentvatne
Copy link
Member

brentvatne commented Mar 10, 2021

right, if you eject and build the app then you will need to publish with the --target bare flag in sdk <= 40. an update that you publish in this way will not run in Expo Go. the flag won't be needed in sdk 41+, and published updates will run in both Expo Go and your ejected apk, assuming the native runtime is compatible (depends on what changes you make after ejecting).

the process you're using right now (eject, do some modifications, build apk) is similar to how EAS Build works for managed apps, which is why a similar approach to ota updates is required there

@DavidUnzue
Copy link

I can confirm, that running expo publish with --target bare solved the issue. Thanks 👍

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

No branches or pull requests

6 participants