Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EAS Build (Android) .apk Crashes, Expo Build .apk Runs Correctly

I'm updating a React Native app to EAS Build, after using expo build for several years. The app works via the development server.

After running eas build, the .apk file builds successfully, but immediately crashes when opened on a device.

My error log is:

TypeError: undefined is not an object (evaluating 't.indexOf')
Running "main" with {"rootTag":1}
Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

Has anyone run into this error?

like image 698
Andrew Fredette Avatar asked Oct 26 '25 08:10

Andrew Fredette


1 Answers

I also had problems, but after reading the documentation some things changed.

  1. Are you migrating an Expo managed app from "expo build"? Learn about the differences.

  2. They must create an index file (reference), with:

    import { registerRootComponent } from 'expo';
    import App from './src/App';
    
    registerRootComponent(App);
    

    (If the App.js is in the root, delete the /src so they have ./App)

    And then, from the package.json, delete the entire line of main.

  3. And [this is the most difficult step] (https://docs.expo.dev/build-reference/migrating/#metroconfigjs--must-export-the-entire-default

, it cost me

like image 106
leandro suarez Avatar answered Oct 29 '25 10:10

leandro suarez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!