React Native App - Application X has not been registered

Application X has not been registered. This is either due to a require() error during initialization or failure to call AppRegistry.registerComponent

I got this error on a relatively new react-native project while running on Android emulator. It took me sometime to figure out what was wrong.

The problem was that I have changed the name of component from the one specified during the initial react native project creation (using react-native init TestProject). I have made following change in - i.e., changed my component name from TestProject to TodoProject.

AppRegistry.registerComponent('TodoProject', () => TodoProject);

But the application name used during react-native init is also hardcoded in the native code (under android and ios directories). Modifying the name only in javascript side leads to name conflict.

To fix this I changed the name passed in first argument of registerComponent back to TestProject and it started working.

AppRegistry.registerComponent('TestProject', () => TodoProject);