Home » Reactjs » React-Native: Application has not been registered error

React-Native: Application has not been registered error

Posted by: admin November 30, 2017 Leave a comment

Questions:

I am currently going through the React-Native tutorials. I began with the Getting Started tutorial, where I made a new react native project and successfully managed to run the project on my device.

I then started the Props tutorial, I copied the code snippet and tried to run the project again and had the following error message show up on my screen.

Answers:

I guess it is an error caused by not matching name of project and your registered component.

You have inited project with one name, i.e.

react-native init AwesomeApp

But in your index.ios.js file you register other component

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

When it must be

AppRegistry.registerComponent('AwesomeApp', () => Bananas);

Try to fix it.

Questions:
Answers:

Most of the times the problem is that you have another react-native start (i.e. React Native Packager) server running either on another terminal or another tab of TMUX (if you are using TMUX).

You need to find that process and close it, so after running react-native run-ios for instance, it will establish a new packager server that registered for that specific application.

Just find that process using:

ps aux | grep react-native

find the process id (PID) and kill the packager process using kill command (e.g. kill -9 [PID]). You should find the launchPackager.command app in macOS, not sure about the other operating systems.

Then try to run the run-ios (or android) again. You should be able to see the new path after running the new packager server, e.g.:

Looking for JS files in
   /Users/afshin/Desktop/awesome-app 

Questions:
Answers:

First of all you must start your application:

react-native start

Then, you must set your application name as the first argument of registerComponent.

It works fine.

AppRegistry.registerComponent('YourProjectName', () => YourComponentName);

Questions:
Answers:

Modify MainActivity like this,

@Override
protected String getMainComponentName() {
    return "Bananas"; // here
}

Questions:
Answers:

I had the same problem and for me the root cause was that I ran (react-native start) the packager from another react-native folder (AwesomeApp), while I created another project in an other folder.

Running the packager from the new app’s directory solved it.

Questions:
Answers:

Rather than changing the name in AppRegistry ,

Run react-native init Bananas , this will create react boilerplate code for Bananas project and AppRegistry.registerComponent will automatically point to bananas

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

Questions:
Answers:

you need to register it in index.android.js / index.ios.js

like this:

'use strict';

import {
    AppRegistry
} from 'react-native';

import app from "./app";

AppRegistry.registerComponent('test', () => app);

Questions:
Answers:

This can also be due to Root component name starts with lowercase.

Recorrect it or rather create the project once again with a PascalCase name.

e.g. ignite new HelloWord