Could not load embedded manifest (android)

ExpoKit app is working perfectly until I try to generate a signed APK. When I install this APK on my phone, I get this error, saying “could not load embedded manifest, are you sure you published, etc…”

This is very similar to here: https://github.com/expo/expo/issues/1916

But in that case, the bundle path and manifest path were not getting written in app.json after publish. In my case, these keys are successfully written and the associated files are generated at the correct folder after publish. Everything appears as it should, but I still receive this error.

I’ve remade the project several times from scratch, as well as changing the slug and pretty much every relevant parameter I can think to refresh. No luck.

What else can I try to debug this?

3 Likes

Still no response so I’ll try to provide more context. In app.json, I’ve turned “updates” / “enabled” to false. Perhaps that has something to do with the issue? I turned it off because the cached app never stored my assets properly, and the app would break any time it loaded from the expo servers.

Second point is that I installed the app using “adb install” which I think is the method suggested in your docs. Not sure if that would be any different to using Android console. But just another note.

I am experiencing this issue as well with SDK 30. It was working fine before we upgraded from SDK 27.

I never had any defaults set, but I enabled updates and came to the same issue. Curiously, I tracked down what seemed to be the root cause (a function in ExponentManifest.java that tries to only use cached assets), or so I thought since the function still seemed to be getting called even with updates enabled.

ExponentManifest.java

  // this is used only if updates.enabled == false
  public void fetchEmbeddedManifest(final String manifestUrl, final ManifestListener listener) {
    String httpManifestUrl = httpManifestUrlBuilder(manifestUrl).build().toString();

    Request.Builder requestBuilder = ExponentUrls.addExponentHeadersToManifestUrl(httpManifestUrl, manifestUrl.equals(Constants.INITIAL_URL));
    requestBuilder.header("Exponent-Accept-Signature", "true");
    requestBuilder.header("Expo-JSON-Error", "true");
    String finalUri = requestBuilder.build().url().toString();

    String embeddedResponse = mExponentNetwork.getClient().getHardCodedResponse(finalUri);

    try {
      JSONObject embeddedManifest = new JSONObject(embeddedResponse);
      embeddedManifest.put(ExponentManifest.MANIFEST_LOADED_FROM_CACHE_KEY, true);
      fetchManifestStep3(manifestUrl, embeddedManifest, true, listener);
    } catch (Exception e) {
      listener.onError(new Exception("Could not load embedded manifest. Are you sure this experience has been published?", e));
      e.printStackTrace();
    }
  }

And here is the logcat output that drove me there:

10-25 13:33:48.042 9580-9580/? E/c: Could not load app: java.lang.Exception: Could not load embedded manifest. Are you sure this experience has been published?
10-25 13:33:48.045 9580-9580/? W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
10-25 13:33:48.045 9580-9636/? D/libEGL: loaded /vendor/lib/egl/libGLESv2_adreno.so
10-25 13:33:48.045 9580-9580/? W/System.err:     at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
        at org.json.JSONTokener.nextValue(JSONTokener.java:94)
        at org.json.JSONObject.<init>(JSONObject.java:159)
        at org.json.JSONObject.<init>(JSONObject.java:176)
        at host.exp.exponent.g.c(ExponentManifest.java:415)
        at host.exp.exponent.c.a(AppLoader.java:71)
        at host.exp.exponent.experience.b.onCreate(DetachActivity.java:95)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Another bit of weirdness that @pcowgill and I noticed in our project is that Expoview seems to be still pegged from v27, but maybe that was due to the last time we had to start a new project and detach.

1 Like

Faced exactly the same problem. It worked fine on expo 27 but stopped after upgrade to expo 30.

Hey guys! Could you please ensure that the URL that is returned in MainActivity.java in publishedUrl is the same as the one at AppConstants.java around lines 30–31?

  // MainActivity.java

  @Override
  public String publishedUrl() {
    return "exp://exp.host/@sjchmiela/playground";
  }
  // AppConstants.java

        // ADD EMBEDDED RESPONSES HERE
        // START EMBEDDED RESPONSES
        embeddedResponses.add(new Constants.EmbeddedResponse("https://exp.host/@sjchmiela/playground/index.exp", "assets://shell-app-manifest.json", "application/json"));
        embeddedResponses.add(new Constants.EmbeddedResponse("https://d1wp6m56sqw74a.cloudfront.net/%40sjchmiela%2Fplayground%2F1.0.0%2F4ce7dc3556eef20f4b9a9e80e369c0e6-30.0.0-android.js", "assets://shell-app.bundle", "application/javascript"));
        // END EMBEDDED RESPONSES

This is the code that is generated at the moment. Could you please try copying URL of the embedded response to the publishedUrl? In my case I would copy https://exp.host/@sjchmiela/playground/index.exp and put into publishedUrl.

Let me know if this helps you solve the issue!

1 Like

works like a charm!

hi all, what expo command line tool are you guys using? we’ve recently migrated from exp to expo, and now all our updates and fixes go to the expo cli. We’ve made some updates to how the manifestUrl gets processed, but that is only available with the more recent expo. Could you try updating the cli (if you havent already) and check if you are still seeing this problem?

Fixed in the latest release of expo-cli (2.2.6). :slightly_smiling_face: npm i -g expo-cli will fix future ejects. :tada:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.