Android production build high crash rate

SDK 35, ejected with ExpoKit.
Getting high crash rate on Android with:

java.lang.RuntimeException: 
  at host.exp.exponent.experience.BaseExperienceActivity$2.run (BaseExperienceActivity.java:196)
  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:7058)
  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:965)

Sometimes:

java.lang.RuntimeException: Expo encountered a fatal error: Unexpected end of script

or

java.lang.RuntimeException: Expo encountered a fatal error: Unexpected EOF

Any advice on how to debug?

3 Likes

This is most likely because of the GCM library mentioned in this issue: https://github.com/expo/expo/issues/4207.

Attempts at a resolution includes “upgrading” to FCM, if you are using push notifications from Expo: https://docs.expo.io/versions/v35.0.0/guides/using-fcm/.

You can also try what I’m doing, which is to simply follow the removal steps in the above guide, as we are using OneSignal for push notifications. So far, it seems like it has fixed the issue. There is also a line in app/build.gradle referencing the Gcm library, which I also removed in addition to the line in AndroidManifest.XML mentioned in the guide above.

Hope you manage to solve it.

2 Likes

Thanks for advice! Still crashes for some reason.

I’ve tried removing GCM, also removed the GCM line in app/build.gradle and published a new build, same errors.

We are also getting this error. We haven’t used GCM, we added the FCM settings on March 7.

1 Like

Hey @fredrikschweinebarth, did you have this error before adding FCM? I’ve started seeing this error after upgrading to SDK35, was on SDK30 before that with no crashes.

@andrey we had actually added FCM before ever shipping the app live, so no. (We are also not ejected, FWIW).

Also getting this exact error. SDK 35, expo kit project.

Same error on a managed expo app sdk 35.

Not a huge crash rate but still too big to be left unsolved. Any leads ? Not using any notifications at all in the app.

1 Like

My crash rate is higher than “Bad behavior threshold”. The app is probably penalized in Google Play search because of that.

Same issue here on Expo 35 managed app

I tired installing my app on 5 different Android devices and could only reproduce the crash on one model: Huawei Honor 8a - crashes on app load. The app works fine in the expo client and I’m not receiving any Sentry bug reports either.

After installing a system update on the Huawei phone it was no longer crashing and worked perfectly, however according to the logs its not just Huawei phones crashing its multiple different phone models.

No idea how to proceed with debugging or fixing this.

1 Like

Has someone managed to fix that? We’re having same problem on SDK36 with FCM (not ejected)

I didn’t :frowning: Haven’t updated to SDK36 yet.

Hi

I ran into this “Unexpected end of script” error in December and did some digging. In my case I was using the managed workflow, but I think this is the same issue regardless.

As far as I know this is caused by incomplete OTA updates. e.g. if the app starts downloading the bundle but is closed before the download finishes then the app will try to load the truncated bundle the next time it starts and will crash with an “Unexpected end of script” error. I was able to reproduce this by installing an APK, publishing an update, and then repeatedly opening and closing the app to try to catch it in the process of downloading the OTA update. At the time I was on wifi with a weak signal which might have helped to reproduce the problem.

See also my comments here:


In that first comment I quote a suggested workaround from @charliecruzan (basically doing the OTA updates yourself instead of letting Expo do the automatic OTA update on start.) This seems to have fixed it for me, but my app is not on the Play store and only has a single user at the moment, so I can’t say for certain.

I was later able to force the crash by deliberately truncating a bundle and letting the app do an OTA update with the bad bundle:

$ expo export --public-url https://example.com/blah/
$ rsync -avxz --progress --delete --stats dist/ example.com:/blah/
$ rm -r dist
$ expo ba --public-url https://example.com/blah/android-index.json
$ expo export --public-url https://example.com/blah/
[Manually truncate dist/bundles/android-*.js] 
$ rsync -avxz --progress --delete --stats dist/ example.com:/blah/

So I suggest you try the workaround. It won’t fix a deliberately broken bundle, but it should hopefully avoid issues with partially downloaded bundles during automatic OTA updates.

Also, apparently the Expo team is busy with a rework of the OTA updates system.

1 Like

This is today response from one of our clients. Expo 36, managed workflow, OTA updates is disabled.

That looks to me like an incomplete OTA update that the app tried to load. Because the bundle is incomplete, this will not work and the JS engine throws an “Unexpected end of script” error.

But OTA updates is disabled
screenshot_1

Interesting. Then I’m not sure how the bundle could be truncated/corrupted. I wonder if that update setting is actually disabling the updates.

Tried disabling updates, but still getting crashes :sob:

@adamjnav Any chance there is something wrong with updates and not just JS errors as you mentioned here High crash rate on Android SDK35? (I though it worked initially, but then crash rate came back up)

I got error same when I installed apk. I open app crashes once time and open again my app work correctly. I didn’t fix it about 1 months. I need helps