How to set publishedUrl, embeddedResponses and embedded manifest correctly?


I want to host my application with my own server. Also, I want to put my bundle and manifest that generated by expo export into app that the application can load them during my server is down. Here is what I have done:

Step 1.
Fisrt, I follow the tutorial Hosting An App on Your Servers to export my bundle and assets that generated by expo export --publish-url After executing the command, I will got a dist folder that looks like:

β”œ assets
    β•° [all images and ttf here]
β”œ bundles
    β”œ android-32898736a2d4fa1cf3aa6baf8b58ea30.js
    β•° ios-cd9489075273dd38190795a6cdcc3a0f.js
β”œ android-index.json
β•° ios-index.json 

So, I started a very simple HTTP server with IP address: and port 8000 to serve these files.

Step 2.
Then, I open the android project with Android Studio. I replaced the return value of function publishedUrl() in android/app/src/main/java/host.exp.exponent/MainActivity:

public class MainActivity extends DetachActivity {

  public String publishedUrl() {
    return "exp://";
    //return "exp://<my project name>";

Step 3.
In order to make my application do work offline, I modified

static {
    List<Constants.EmbeddedResponse> embeddedResponses = new ArrayList<>();

        embeddedResponses.add(new Constants.EmbeddedResponse("", "assets://shell-app-manifest.json", "application/json"));
        embeddedResponses.add(new Constants.EmbeddedResponse("", "assets://shell-app.bundle", "application/javascript"));
    EMBEDDED_RESPONSES = embeddedResponses;

Step 4.
Replace shell-app-manifest.json and shell-app.bundle

dist/bundles/android-32898736a2d4fa1cf3aa6baf8b58ea30.js -> android/app/src/main/assets/shell-app.bundle
dist/android-index.json -> android/app/src/main/assets/shell-app.bundleshell-app-manifest.json


After all are done, I build the application into .apk and install the app into my android device. The application work fine when my HTTP server is online. But, if I shut down the HTTP server, the application keep showing Error:

Uncaught Error: Failed to connect to /

hh:mm:ss Fatal Error

Did I do anything wrong? Any help is very grateful

Thank you

1 Like

Any luck with this?

Nope, I haven’t get any breakthrough. I will keep trying after my project is done.