App crashes on startup

  1. SDK Version: 36
  2. Platforms(Android/iOS/web/all): Android

Since I updated to sdk36 android standalone is crashing immediately after showing splash screen. Even nothing going to sentry.

Is there any tip how can I debug what’s wrong? It works fine in expo cli.

Note: at sometime close to sdk update, I have also updated my phone to latest oxygen os (Android 10).

Thanks

One option is to use process of elimination. Comment out sections of code, test it out, comment out more sections, and repeat until you narrow down the section of code that’s causing the issue.

Thanks. I have attempted that a couple of times. But as it needs a complete rebuild, download and install, it is extremely slow. Plus builds on expo site queues for about 30mins (even at odd hours).

Only manageable way is to find out how to capture the error.

You should be able to see the crash using adb logcat.

But there is a bug causing crashes on Android when in dark mode. Dark mode on Android was introduced in SDK 36, so if this started after upgrading that might be the cause.

It might also be possible to use Crashlytics, but I haven’t tried it.

1 Like

Thanks. That’s a great idea. I’ll try that.

I think I was able to track the faulty line. I’ve this line in a file (outside component which is why it was crashing at startup; putting in render causes error in just that screen)

const googleMapAPIKey = Platform.select({
  android: Constants.manifest.android.config.googleMaps.apiKey,
  ios: Constants.manifest.ios.config.googleMapsApiKey
});

The error is:

Expo encountered a fatal error: TypeError: undefined is not an object (evaluating ‘h.default.manifest.android.config.googleMaps’), stack: @1307:533 v@2:1474 @1253:1789 v@2:1474 @1252:307 v@2:1474 @953:200 v@2:1474 @663:312 v@2:1474 @6:82 v@2:1474 d@2:876 global code@1505:4

I inspected in expo client, both properties work perfectly. Need to figure out why it’s crashing on android standalone (didn’t verify in ios standalone).

I’ve not needed to reference Constants.manifest in any of my apps yet, so can’t say whether it works for me.

The following link does imply it should work on iOS (and I see no reason it should work on one platform and not the other):

https://docs.expo.io/versions/v36.0.0/sdk/map-view/#deploying-google-maps-to-a-standalone-app

One thing I’m not sure of, though: How safe is it putting things like Google Maps API key in the manifest? I suppose there’s nowhere else to put them, but is it a problem if the user unpacks the APK and gets the API key from it?

We have had identical symptoms as you describe (crashing on launch on Android, only in builds, not in dev, ever since upgrading to SDK36). Just wanted to pass along that we have tracked it down to dark mode on Android. If we disable dark mode and reinstall the app, then it works. This has been our workaround for our customers until we can track the root cause.

1 Like

Hi, yes, thanks, there’s a known issue with SDK 36 and dark mode on Android, but that causes a different error that looks something like this:

Fatal Exception: java.lang.RuntimeException
Expo encountered a fatal error: Error while updating property 'width' in shadow node of type: RCTView

That’s a good question. I had a cred in JS config until I realized anyone read it and find it there. That’s why I thought only safe place is app.json as we already have other creds as instructed by Expo. I need to find out if that’ll be safe!

Also I guess the reason, it broke in standalone, is that during build expo removes (i guess moves to somewhere else) it (may be selective ones) from app.json as they said

Most configuration from app.json is accessible at runtime from your JavaScript code via Constants.manifest . Sensitive information such as secret keys are removed. See the "extra" key below for information about how to pass arbitrary configuration data to your app.

Another thing, I’ve tried to use adb logcat. Though I saw the exception there it wasn’t much helpful. I tried to configure the crashlytics and had to give up midway. Not sure how (i guess because I already have the firebase setup for other purpose), later I got a notification about the crash and exact problem. :sunglasses:

1 Like

A pull request has been merged to fix this dark mode related crash:

https://github.com/expo/expo/pull/6825#issuecomment-579016559

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.