Android app crashing on upgrade from SDK 34 to 37

Hi, we have an ExpoKit app that was previously SDK 34 that we’re upgrading to SDK 37. Most things are working fine, but once we’re out of dev and try testing upgrading, on Android the app keeps crashing. This can be fixed by clearing local storage; after that, the app runs fine.

This is the error from logcat:

java.lang.RuntimeException: Expo encountered a fatal error: 34.0.0 is not a valid SDK version. Options are 37.0.0, UNVERSIONED.
at host.exp.exponent.experience.BaseExperienceActivity.lambda$consumeErrorQueue$0$BaseExperienceActivity(BaseExperienceActivity.java:204)
at host.exp.exponent.experience.-$$Lambda$BaseExperienceActivity$zZZNiLUhJmY4AlwF2loJATXcbqc.run(Unknown Source:2)
at android.app.Activity.runOnUiThread(Activity.java:6404)
at host.exp.exponent.experience.BaseExperienceActivity.consumeErrorQueue(BaseExperienceActivity.java:184)
at host.exp.exponent.experience.BaseExperienceActivity.addError(BaseExperienceActivity.java:73)
at host.exp.exponent.kernel.Kernel.handleReactNativeError(Kernel.java:1051)
at host.exp.exponent.kernel.Kernel.handleError(Kernel.java:1056)
at host.exp.exponent.experience.ExperienceActivity.setManifest(ExperienceActivity.java:418)
at host.exp.exponent.experience.ExperienceActivity$2$2.run(ExperienceActivity.java:221)
at host.exp.expoview.Exponent.runOnUiThread(Exponent.java:218)
at host.exp.exponent.experience.ExperienceActivity$2.onManifestCompleted(ExperienceActivity.java:215)
at host.exp.exponent.AppLoader.resolve(AppLoader.java:240)
at host.exp.exponent.AppLoader.resolve(AppLoader.java:215)
at host.exp.exponent.AppLoader.access$000(AppLoader.java:20)
at host.exp.exponent.AppLoader$5.onBundleLoaded(AppLoader.java:337)
at host.exp.expoview.Exponent$2$1.run(Exponent.java:452)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7073)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

My understanding is that this means the app is trying to run our old SDK-34-versioned JS bundle instead of the SDK 37 one it was built with (and that should have also been published). Once we clear the cached version by clearing internal storage, it pulls in the right version.

Since we’re not 100% sure of the cause, we’ve tried a few things that didn’t help:

  1. created a new release channel to make sure it was not serving older versions (and did this for each following change)
  2. updated the kernel-manifest.json file in the android directory to match the expo repo’s sdk-37 branch since that wasn’t auto-updated
  3. re-added sdkVersion: "37.0.0" to the app.json, since the expo upgrade tool removed that line
  4. verified that the expo package has a version of 37+ in its package.json, and that version 34 was not mentioned anywhere else in our repo

We focused on the sdkVersion in the manifests since that seems to be where this error originates: https://github.com/expo/expo/blob/sdk-37/android/expoview/src/main/java/host/exp/exponent/experience/ExperienceActivity.java#L429

Our app uses updates.checkAutomatically: 'ON_ERROR_RECOVERY' to control when users get updates. Next up we’re experimenting with changing that to see if we can get the app to maybe re-download a correctly-versioned JS bundle.

Does anyone have advice to help us figure out how this should be working? By everything I can read, the app should be using the JS bundle it’s built with, or at least only download the newly-versioned-for-SDK-37 JS bundle we published.

Some updates after further troubleshooting:

  • We found that changing the value of “checkAutomatically” did not have any impact on the crash
  • via some logging debugging, we’re finding that our JS code never runs before the crash, so we’re reasonably confident this is a configuration and/or ExpoKit issue
  • We checked the publish:history for our app and saw the most recent JS bundles did indeed have an sdkVersion of “37.0.0”.

Our next line of thinking is that it’s possible the release channel configuration isn’t getting picked up properly and it’s using an old release channel, so we’ll be trying to debug whether that’s the case in the Java code next.

However, it still seems more likely that the app is using an old cached version of the bundle in local storage rather than the one it was shipped with, so we’re looking into that too.

@esamelson - any ideas about this?

We found what was causing this today – it was a bit of a misconfiguration issue.

I had tried to clean up the generated expokit files from the git worktree, and we scripted adding them back when needed. However, because we didn’t understand when all of the pieces of the files were generated, we got the ordering wrong.

We needed to lay down the generated files before running expo publish. Since we didn’t, some “EmbeddedResponses” didn’t get added to AppConstants.java (this appears to happen in the expo publish step, but it will not error if the file is missing), which apparently results in our embedded manifest not getting used.

I googled “host.exp.exponent.experience.BaseExperienceActivity.lambda$consumeErrorQueue$0” and it led me to only search result here.

I am getting this on Expo SDK 38 managed flow on multiple devices (MI 8 Lite (platina), Galaxy A2 Core (a2corelte), Galaxy S10 (beyond1) on (Android 10, Android 8.1) with below call stack:

java.lang.RuntimeException: 
  at host.exp.exponent.experience.BaseExperienceActivity.lambda$consumeErrorQueue$0 (BaseExperienceActivity.java:216)
  at host.exp.exponent.experience.-$$Lambda$BaseExperienceActivity$zZZNiLUhJmY4AlwF2loJATXcbqc.run (-.java:2)
  at android.os.Handler.handleCallback (Handler.java:883)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:7777)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1047)

Any help is appreciated.

1 Like

I got the same issue today on an Samsung A50s - andoird 10, It happened multiple times (3 times) on a device.
I have updated the expo SDK from 37-to 38 for my latest release version.

  at host.exp.exponent.experience.BaseExperienceActivity.lambda$consumeErrorQueue$0 (BaseExperienceActivity.java:216)
  at host.exp.exponent.experience.-$$Lambda$BaseExperienceActivity$zZZNiLUhJmY4AlwF2loJATXcbqc.run (-.java:2)

Any help is appreciated.

1 Like

We’re getting the same crash errors, it happens mostly in Galaxy and Motorola models (many versions).

I’m getting the same error, any update on this?

at host.exp.exponent.experience.BaseExperienceActivity.lambda$consumeErrorQueue$0 (BaseExperienceActivity.java:204)
  at host.exp.exponent.experience.-$$Lambda$BaseExperienceActivity$zZZNiLUhJmY4AlwF2loJATXcbqc.run (-.java:2)

Same issue here. Really need a fix for this.

I also received the same error, Model Samsung S9 Android 10, I use the managed project.

java.lang.RuntimeException:
at host.exp.exponent.experience.BaseExperienceActivity.lambda$consumeErrorQueue$0 (BaseExperienceActivity.java:216)
at host.exp.exponent.experience.-$$Lambda$BaseExperienceActivity$zZZNiLUhJmY4AlwF2loJATXcbqc.run (-.java:2)

1 Like

We are also seeing this with SDK 38 with multiple devices - Galaxy S9 (Android 10), Motorola moto e6 (Android 9), Galaxy S7 Edge (Android 8).

java.lang.RuntimeException: 
  at host.exp.exponent.experience.BaseExperienceActivity.lambda$consumeErrorQueue$0 (BaseExperienceActivity.java:216)
  at host.exp.exponent.experience.-$$Lambda$BaseExperienceActivity$zZZNiLUhJmY4AlwF2loJATXcbqc.run (-.java:2)
1 Like

I have a user experiencing this crash on SDK 38 on a Samsung Galaxy s9. They have reported they can get the app to work (at least for a little bit before crashing) if they start the app in Airplane mode then turn it off after a bit. I have my app configured to manually check and download new Expo updates but this step gets skipped if they are offline on startup. Hope this helps with troubleshooting…

1 Like

Same here:

Samsung Galaxy S7
Android 8.0 (SDK 26)
java.lang.RuntimeException: 
  at host.exp.exponent.experience.BaseExperienceActivity.lambda$consumeErrorQueue$0 (BaseExperienceActivity.java:216)
  at host.exp.exponent.experience.-$$Lambda$BaseExperienceActivity$zZZNiLUhJmY4AlwF2loJATXcbqc.run (-.java:2)
  at android.os.Handler.handleCallback (Handler.java:789)
  at android.os.Handler.dispatchMessage (Handler.java:98)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6944)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

I’m on SDK 37. Will experiment with bumping versions

@notbrent @esamelson Any ideas on this? I’m continuing to see the same crashes on various Samsung devices

Are you able to run adb logcat on any of these devices to see what message is logged just before that stack trace?

If you can run adb logcat on one or more of the affected devices then hopefully you will get a message like “Expo encountered a fatal error: XXX” which should give us some more information about the cause(s) of the crashes.

Is there a way we can pack and send that logcat file to the developer on facing the error, of course with the permission of user, but I can’t seem to find any other way except that to get more information on this issue.

Here also with several errors on Android with SDK39 (reanimated 2 with turboModules activated):

<un: 
  at host.exp.exponent.experience.BaseExperienceActivity.lambda$consumeErrorQueue$0 (BaseExperienceActivity.java:210)
  at host.exp.exponent.experience.-$$Lambda$BaseExperienceActivity$zZZNiLUhJmY4AlwF2loJATXcbqc.run (-.java:2)
  at android.os.Handler.handleCallback (Handler.java:789)
  at android.os.Handler.dispatchMessage (Handler.java:98)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6944)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

@notbrent @esamelson i don’t really know what to do or how to debug because the code is practically the same (as running un SDK37) and most of my android users are affected, the image above shows the statistics since I released the app with SDK39 since about November 6,

NOTE: these errors I see from the google play console and my app is standalone and uses manage workflow

app.json

{
  "expo": {
    "name": "Ámbito Dólar",
    "slug": "ambito-dolar",
    "privacy": "hidden",
    "platforms": ["android", "ios", "web"],
    "version": "3.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "userInterfaceStyle": "automatic",
    "ios": {
      "bundleIdentifier": "im.outa.AmbitoDolar",
      "buildNumber": "38",
      "infoPlist": {
        "CFBundleDevelopmentRegion": "es",
        "UISupportedInterfaceOrientations": ["UIInterfaceOrientationPortrait"],
        "UISupportedInterfaceOrientations~ipad": [
          "UIInterfaceOrientationLandscapeLeft",
          "UIInterfaceOrientationLandscapeRight"
        ],
        "UIRequiresFullScreen": true,
        "LSApplicationQueriesSchemes": ["twitter", "tg", "instagram", "fb"]
      },
      "supportsTablet": true,
      "config": {
        "usesNonExemptEncryption": false
      }
    },
    "android": {
      "package": "im.outa.AmbitoDolar",
      "versionCode": 38,
      "googleServicesFile": "./google-services.json",
      "icon": "./assets/icon.android.png",
      "adaptiveIcon": {
        "foregroundImage": "./assets/icon.android.adaptive.foreground.png",
        "backgroundImage": "./assets/icon.android.adaptive.background.png"
      },
      "permissions": [],
      "allowBackup": false,
      "softwareKeyboardLayoutMode": "pan",
      "useNextNotificationsApi": true
    },
    "notification": {
      "icon": "./assets/icon.notification.png",
      "color": "#2ECC71"
    },
    "hooks": {
      "postPublish": [
        {
          "file": "sentry-expo/upload-sourcemaps",
          "config": {
            ...
          }
        }
      ]
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "assets/!(design)/**",
      "node_modules/@expo/vector-icons/**/{MaterialIcons,MaterialCommunityIcons,FontAwesome5*}.ttf"
    ],
    "experiments": {
      "turboModules": true
    }
  }
}

Thanks !!!

reanimated2 is experimental and we don’t recommend using it in production. if you can create a minimal reproducible example, please report to the reanimated 2 repository

Thanks Brent for being always present :heart:

Yes, I know that the state of reanimated2 is alpha and the truth is that I cannot create a reproducible case, it is totally random in several android phones and these failures / ANR I see them from the google play console,

I have several stack traces but I don’t know if that could help something :thinking:

1 Like

I created an issue in the reanimated 2 repository to see if they can give us some help, day after day our case numbers grow exponentially :sob: