expo: "Could not load app. Can't connect to internet. Please try again" - SDK27-30 w/ ExpoKit

I recently updated to SDK27 (am using ExpoKit), and I’m trying to use the offline JS bundle functionality. I followed the instructions from [here] (https://gist.github.com/janicduplessis/30ec95451733d34ffcf7d5cb27ba0e28), but I keep seeing this screen after rebuilding:

image

I double-checked that:

  • detach-scripts contains both run-exp.bat and run-exp.sh
  • app/build.graddle contains apply from: 'expo.gradle'
  • android/app contains expo.gradle

And now I’m not sure if I did the right thing, but what I’ve done is:

  • Since I wasn’t sure what “my manifest” is and the build was asking for it, I created a shell-app-manifest.json in my android\app\src\main\assets, with the following content:
{
  "android": {
    "publishBundlePath": "android/app/src/main/assets/shell-app.bundle",
    "publishManifestPath": "android/app/src/main/assets/shell-app-manifest.json"
  },
}

But it seemed to be the right move since build completes successfully, can confirm it creates a shell-app.bundle in src/main/assets, and installs on device successfully. But then if I stop wifi and run the app I get the initial blue screen error again.

Is it something that I’m missing?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (11 by maintainers)

Most upvoted comments

Wow, thank you so much for the detailed response. That was indeed the case, I hadn’t changed publishedUrl in MainActivity. Thanks for solving my oversight and teaching me a bit of how the internals work. 😄

The way app loading works in rough is:

  • static block in AppConstants registers embedded responses, i. e. contents for a sort of a caching proxy, so when the app loader asks for eg. https://exp.host/@sjchmiela/android292 it doesn’t need to do a real network request — the response is embedded right here (assets://shell-app-manifest.json).
  • a URL to the manifest is being constructed basing on MainActivity#publishedUrl() (eg. exp://exp.host/@sjchmiela/android292 is being turned into https://exp.host/@sjchmiela/android292 by ExponentUrls.java)
  • app loader tries to fetch the manifest from this URL (it may hit the embedded response)
  • the manifest contains information about the app + bundle URL
  • app loader fetches the bundle URL and runs it.

For embedded responses to work, username and app name must match between MainActivity and the embedded response defined in AppConstants.

When you publish an application on account @newbetteraccount, expo-cli will register an embedded response for @newbetteraccount/theapp and if MainActivity still points to @theoriginalaccount/theapp, embedded response won’t be hit. So if the app works in offline mode when publishing from one account and not from the other, make sure publishedUrl reflects the desired change too. 🙂

Thanks for the reply! Can confirm it works. Publishing the app with expo-cli 2.4.0 automatically removes the suffix on that line. Running then the release version of the app for the first time on a device on airplane mode correctly loads the JS bundle. Thank you!

It’s definitely not the same issue, at least for me. I’ve checked that the bundle gets generated when I run exp publish and the app still doesn’t start offline. I’ll be able to do more tests in a couple of days, and I’ll try to replicate the behaviour on a new app.