After ejecting, cant find app.manifest

We are ejecting to start the setup for in-app payments. After ejecting I was able to cleanup a few errors and get the project to build for android but crashes immediately on opening.

I have created a new bare workflow for comparison as well as reading through some similair issues found here and cannot find any differences in the main java files. We’re ok dropping expo-updates for the time being if that turns out to be a possible solution/recommendation.

Error abd logcat

memtrack: Couldn't load memtrack module
08-20 12:22:47.115  8216  8216 E .aahern.protec: Unknown bits set in runtime_flags: 0x8000
08-20 12:22:47.453  8216  8216 E EmbeddedLoader: Could not read embedded manifest
08-20 12:22:47.453  8216  8216 E EmbeddedLoader: java.io.FileNotFoundException: app.manifest
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.content.res.AssetManager.nativeOpenAsset(Native Method)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.content.res.AssetManager.open(AssetManager.java:824)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.content.res.AssetManager.open(AssetManager.java:801)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at expo.modules.updates.loader.EmbeddedLoader.readEmbeddedManifest(EmbeddedLoader.java:73)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at expo.modules.updates.UpdatesController.start(UpdatesController.java:285)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at expo.modules.updates.UpdatesController.initialize(UpdatesController.java:96)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at com.aahern.protect.MainApplication.onCreate(MainApplication.java:85)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.app.ActivityThread.access$1300(ActivityThread.java:219)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.os.Handler.dispatchMessage(Handler.java:107)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.os.Looper.loop(Looper.java:214)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at android.app.ActivityThread.main(ActivityThread.java:7356)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at java.lang.reflect.Method.invoke(Native Method)
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)      
08-20 12:22:47.453  8216  8216 E EmbeddedLoader:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
08-20 12:22:47.453  8216  8216 E AndroidRuntime: FATAL EXCEPTION: main
08-20 12:22:47.453  8216  8216 E AndroidRuntime: Process: com.aahern.protect, PID: 8216
08-20 12:22:47.453  8216  8216 E AndroidRuntime: java.lang.AssertionError: The embedded manifest is invalid or could not be read. Make sure you have configured expo-updates correctly in android/app/build.gradle. app.manifest
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at expo.modules.updates.loader.EmbeddedLoader.readEmbeddedManifest(EmbeddedLoader.java:78)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at expo.modules.updates.UpdatesController.start(UpdatesController.java:285)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at expo.modules.updates.UpdatesController.initialize(UpdatesController.java:96)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at com.aahern.protect.MainApplication.onCreate(MainApplication.java:85)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at android.app.ActivityThread.access$1300(ActivityThread.java:219)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:107)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:214)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7356)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
08-20 12:22:47.453  8216  8216 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

build.gradle

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false
]

apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle"

MainApplication.java

public class MainApplication extends Application implements ReactApplication {
  private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(
    new BasePackageList().getPackageList()
  );

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      List<ReactPackage> packages = new PackageList(this).getPackages();
      packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
      return packages;
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }

    @Override
    protected @Nullable String getJSBundleFile() {
      if (BuildConfig.DEBUG) {
        return super.getJSBundleFile();
      } else {
        return UpdatesController.getInstance().getLaunchAssetFile();
      }
    }

    @Override
    protected @Nullable String getBundleAssetName() {
      if (BuildConfig.DEBUG) {
        return super.getBundleAssetName();
      } else {
        return UpdatesController.getInstance().getBundleAssetName();
      }
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    initializeFlipper(this); // Remove this line if you don't want Flipper enabled

    if (!BuildConfig.DEBUG) {
      UpdatesController.initialize(this);
    }
  }

Let me know of any other snippets that could be helpful. Thanks!

1 Like

I just posted this answer on an SE post (https://stackoverflow.com/questions/62944572/where-should-app-manifest-be-found-in-a-react-native-project/63691916#63691916), but thought it useful to post here too. This is for a fresh project, but it will hopefully be useful to you in solving the problem for an ejected Expo project as well.

I ran into this problem today and after much digging found the React Native build was actually crashing out when it tried to use the jest-haste-map , somewhere deep inside the Metro class hierarchy somewhere I can’t remember, but you could trace it and find out if you’re interested. Anyway I could see that jest-haste-map was crashing out and the rest of the code was not getting executed, so the app.manifest was never getting written to the bundle!

However, jest-haste-map was not actually at fault. I had my suspicions about file permissions since Watchman was throwing up the odd warning here and there.

I decided to do a clean setup and build. First off I used (and recommend) sudo expo init since you get the expo-unimodules installed by default which solves the problems associated with installing that by hand (that’s another story !) Choose the minimal bare template.

Next I found that if I ran the Metro server with npm start instead of sudo npm start I got a jest-haste-map error/warning (may have been Watchman, can’t remember). This led me to believe the original build problem (missing app.manifest ) was purely a permissions problem. And indeed it was.

After chown -ing the /tmp folder to root (not sure how safe that is?) and making sure I sudo npm -g installed everything I needed, and made sure to start the Metro server and React Native as root ( sudo npm start and sudo react-native run-android ) the problem was solved.

I could then easily go ahead and make my production AAB or APK and everything worked fine.

Lesson I learned: don’t ignore Watchman. Although React Native may seem to build okay, a Watchman warning/error is actually a clue that something isn’t ok!

So the original problem is that the project and tool chain setup had the incorrect permissions, which caused the jest-haste-map module to fail during the React Native build, which meant the app.manifest file was never written out to the AAB or APK file, hence the error.

Note - it’s quite possible that a sudo chmod -R 777 MyAppFolder will short the problem !

1 Like