Edit this page
Learn about what the Application has not been registered error means and how to resolve it in an Expo or React Native app.
Edit this page
When developing an Expo or React Native app, it's common to run into an error that looks like:
Application "main" has not been registered.
# Or
Invariant Violation: "main" has not been registered.
In this particular error, "main"
can be any string.
The most common cause of this error is that there is an exception thrown in your application before it's able to register itself. When a React Native application loads, there are two steps:
If you're in this situation, the error message you're seeing is a red herring, it's distracting you from the real error that led to the application not being registered.
Look at your logs before this error message to see what may have caused it. A frequent cause is multiple versions of a native module dependency that registers itself as a view — for example this Stack Overflow thread where the poster has multiple versions of react-native-safe-area-context
in their dependencies.
Another possibility is that there is a mismatch between the AppKey
being provided to AppRegistry.registerComponent
, and the AppKey
being registered on the native iOS or Android side.
In managed projects, the default behavior is to use "main" as the AppKey
. This is handled for you automatically, and as long as you don't change the "main"
field in your package.json from the default value then this will just work. If you want to customize the app entry point, see registerRootComponent API reference.
In projects with native code, you will see something like this in your index.js by default:
import { registerRootComponent } from 'expo';
import App from './App';
registerRootComponent(App);
where registerRootComponent
is implemented as:
function registerRootComponent(component) {
AppRegistry.registerComponent('main', () => component);
}
And on the native side, in AppDelegate.m you should see:
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
and in MainActivity.java:
@Override
protected String getMainComponentName() {
return "main";
}
By default, "main" is consistently used throughout the project. If you're running into this error, something has likely changed and these values no longer coincide. Ensure that the names you are registering on the JavaScript side are the ones expected on the native side (if you're using Expo's registerRootComponent
function, that would be "main").
This error can also occur in a few other scenarios, but it's less predictable and the fixes would be more specific to your project. For example, some other cases are:
ps -A | grep "expo\|react-native"
).npx expo start --no-dev --minify
to find the source of the error.