ExpoKit .apks for android crash when opening

We ejected our app a while ago from expo and everything was running fine since then. We managed to add native libraries and upload our app to TestFlight and google play for internal testing. Today we’ve ran into a huge issue that we couldn’t find any solution to.
Whenever we tried to install a new .apk file for android built from Android Studio it would constantly keep crashing with no error. We have Sentry set up in our project, so we would’ve gotten a crash report if it was from our side of the code. The project runs fine in development and production mode from the emulator or if I connect my phone to android studio. Running adb logcat *:E and checking the phone’s crash suggests the following fatal exception:

03-09 14:50:44.136  4156  4156 E AndroidRuntime: FATAL EXCEPTION: main
03-09 14:50:44.136  4156  4156 E AndroidRuntime: Process: com.optimizeapp.optimizeapp, PID: 4156
03-09 14:50:44.136  4156  4156 E AndroidRuntime: java.lang.RuntimeException: Expo encountered a fatal error: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x7c9a4e1e08: I/O error during system call, Connection reset by peer
03-09 14:50:44.136  4156  4156 E AndroidRuntime: 	at host.exp.exponent.experience.a$b.run(BaseExperienceActivity.java:7)
03-09 14:50:44.136  4156  4156 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:873)
03-09 14:50:44.136  4156  4156 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 14:50:44.136  4156  4156 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:214)
03-09 14:50:44.136  4156  4156 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6986)
03-09 14:50:44.136  4156  4156 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
03-09 14:50:44.136  4156  4156 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
03-09 14:50:44.136  4156  4156 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
03-09 14:50:44.460  3907  4154 E libperflog: [LIBPERFLOG] socket_local_client fail = -1

We’re not sure what “Expo encountered a fatal error: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x7c9a4e1e08: I/O error during system call, Connection reset by peer” means or what expo is trying to establish an SSL handshake with.

We’ve spent the entire day searching google for anything related but we’ve hit a roadblock. We even tried creating a fresh expo project and then ejecting and building the .apk and it still throws that error on physical phones. Non-ejected apps work fine and our same iOS ejected app also works fine.

What we noticed is that this error will keep popping up after a fresh install of the app on most WiFi connections, and we can get past it by using a VPN, using the phone’s mobile data while crash the app a couple of times or not at all and then it would work fine. After that the error never comes back again, even without a VPN or when using WiFi. Unless we uninstall the app and install it again, the error would keep showing and crashing the app with a WiFi connection with no VPN.

So we think it has something to do with the connection that Expo is trying to establish but we don’t know what it is.

Disclaimer:
We’ve been having trouble with Expo’s server-based services such as ‘expo publish’ and ‘expo start’ always returning a

Fetching the user profile failed
read ECONNRESET

errors (even from way before ejecting) that we can only get past by with using a VPN and some days it would work fine, so we think that might be related.

Expo Diagnostics:

Expo CLI 3.13.1 environment info:
    System:
      OS: macOS 10.15.2
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.6.0 - /usr/local/bin/node
      Yarn: 1.17.3 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
    IDEs:
      Android Studio: 3.5 AI-191.8026.42.35.5900203
      Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^36.0.0 => 36.0.2 
      react: 16.9.0 => 16.9.0 
      react-native: https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz => 0.61.4 
      react-navigation: ^4.0.10 => 4.0.10

Not sure if this is the issue because iOS seems to be working, but some regions of the world with internet restrictions block various services used by Expo. Sometimes it can help to google the error apart from anything specific to React Native or Expo e.g., “javax.net.ssl.SSLHandshakeException: SSL handshake aborted”, as that opens your results up to any Android devs facing the same issue. That said I don’t see much out there other than issues with really old versions of Android that Expo doesn’t even support, and network problems.

I would recommend trying to isolate the network issues. Find an alternate wifi away from where you work, if possible, make sure no proxies are in effect, etc. and try everything from scratch on a new project. Of course, if all wifi in the area is affected, this may not help, which goes back to potential issues with regional blocking, which may explain why VPN is fine.

Looks like this may be a bug on our end, keeping track in this issue here for anyone else finding this post - Android build error could not load app. hostUri exp.host vs expo.io · Issue #7304 · expo/expo · GitHub

@charliecruzan Thank you, the issue has been fixed based on the github issue you provided.

1 Like