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.
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.
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.
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.
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:
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.
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.