Error: Invariant Violation: "main" has not been registered. Monorepo local build Android build

In your post, please share:

  • Whether you are bare or managed workflow
    managed
  • Your eas-cli version
    5.2.0
  • What you have tried so far
    Google searching and looking at similar posts on this forum.

I am working in a monorepo and I’m getting this error Invariant Violation: "main" has not been registered. when I run the locally built apk in Android Studio.

We have an index.js file in a nested apps/expo folder


import App from './App';

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);

One thing I noticed is that this file is hoisted to the root directory for some reason. Is that the reason for this error? Why does this happen and how can I prevent it? I had to create an App.js file in the root level that imported the App.tsx file in the expo directory for the build to even run.

Any help would be greatly appreciated!

hi there! i’d suggest following this monorepo guide closely to make sure you haven’t missed anything: Work with monorepos - Expo Documentation

if that doesn’t help, try narrowing the problem down further. can you get a hello world app running in the monorepo? if so, then go from there to find what in particular about your configuration is causing this issue. https://expo.fyi/manual-debugging