2

I've been trying to fix this error from a couple weeks ago with no success. The problem is I cannot publish my app because of this.

When I build my expo app for any of both, iOS or Android, the Expo CLI signing process goes well, no errors and generates final bundles but when I install the spa or apk file into a real device it shows the splash screen 4 or 5 times in a row (some kind of loop) and finally shows the following error messages:

Checked out with no results:

https://forums.expo.io/t/application-main-has-not-been-registered/14395

Application main has not been registered

https://forums.expo.io/t/application-main-has-not-been-registered/11753

My package.json looks like this:

{
  "name": "Sxunco",
  "homepage": "https://www.sxunco.com",
  "version": "1.0.3",
  "private": true,
  "main": "node_modules/expo/AppEntry.js",
  "jest": {
    "preset": "jest-expo",
    "transformIgnorePatterns": [
      "node_modules/(?!((jest-)?react-native|react-clone-referenced-element|expo(nent)?|@expo(nent)?/.*|react-navigation|redux-persist|native-base(-shoutem-theme)|native-base|react-native-router-flux))"
    ]
  },....

My App.js:

import React from 'react';
import Root from './src/native/index';
import configureStore from './src/store/index';

const { persistor, store } = configureStore();

export default function App() {
  return <Root store={store} persistor={persistor} />;
}

Ive tried with same results:

  • Adding "appKey": "main" into app.json
  • Adding AppRegistry.registerComponent(‘main’, () => App); into App.js and also expo registerRootComponent(App) (separated and both together, none of that works)
  • Changing "main" path in package.json directly to App.js and register app with above methods manually

When I run build I also run:

exp start --no-dev --minify

So I wait for the server to finish loading and then run expo build:android

Please I don't know what to do, I cannot publish my app because of this.

Karlo A. López
  • 2,548
  • 3
  • 29
  • 56

2 Answers2

1

1) check index.js and make sure yourAppName is registered, not main:

app.json file from root folder:

{
  "name": "TestSvgJoy",
  "displayName": "TestSvgJoy"
}

index.js (from root folder, if you don't have it there you need to update build scripts in Xcode as below)

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

This is how app would look in Xcode:

enter image description here

2) AppDelegate.m should have 2 lines like this

#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

Note: if you are using Expo and app was not detached you can ignore this step.

3) Make sure your root folder contains the index.js or index.ios.js.

Note: If you need custom path of entryFile (index.js or index.ios.js) go to Xcode, project target, Build Phases, Bundle ReactNative code and imagesand provide an extra parameter like ./src/index.ios.js

enter image description here To test things quickly and get more info about the errors go to Xcode, Product, Scheme, Edit Scheme, Run, Build Configuration and set it to Release and run it on the simulator.

enter image description here

Florin Dobre
  • 9,872
  • 3
  • 59
  • 93
  • Hi Florin, thanks for answer. I've tried to put `"main":"App.js"` property over package.json and put `AppRegistry.registerComponent("Sxunco", () => App());` in App.js end but nothing, same result – Karlo A. López Aug 26 '19 at 23:44
  • Hi, Karlo, I updated my answer with more details. Double check step 1 and make sure index.js (or index.ios.js) is present in the root folder. (step 3) – Florin Dobre Aug 27 '19 at 07:46
1

Turns out my App is a function, and I was just passing the function itself to both registration methods (react native & expo):

registerRootComponent(App())

AppRegistry.registerComponent(appName, () => App());

But in registerRootComponent I was missing an arrow function :S

registerRootComponent(()=>App())

:)

Karlo A. López
  • 2,548
  • 3
  • 29
  • 56
  • 1
    I think you don't have to use AppRegistry.registerComponent(appName, () => App()); as expo itself manage that by registerRootComponent. – gypsicoder Aug 28 '19 at 09:11
  • I think you don't have to use AppRegistry.registerComponent(appName, () => App()); as expo itself manage that by registerRootComponent. – gypsicoder Aug 28 '19 at 09:11