[javascript] React-Native: Application has not been registered error

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:

This question is related to javascript facebook reactjs react-native

The answer is


I think the node server is running from another folder. So kill it and run in the current folder.

Find running node server:-

lsof -i :8081

Kill running node server :-

kill -9 <PID>

Eg:-

kill -9 1653

Start node server from current react native folder:-

react-native run-android


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 

This solution worked for me after 2 days of debugging. Change this :

AppRegistry.registerComponent('AppName', () => App);

to

AppRegistry.registerComponent('main', () => App);

The issue will also appear when, in index.js, you have named the app differently from the name you gave it for the android/ios package; probably this happened when you've ejected the app. So be sure that when calling AppRegistry.registerComponent('someappname', () => App), someappname is also used for the native packages or viceversa.


This solved it for me

AppRegistry.registerComponent('main', () => App);

So my index.js file

import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('main', () => App);

And my package.json file:

"dependencies": {
    "react": "^16.13.1",
    "react-dom": "~16.9.0",
    "react-native": "~0.61.5"
},

I figured out where the problem was in my case (Windows 10 OS), but It might also help in Linux as well( You might try).

In windows power shell, when you want to run an app(first time after pc boot) by executing the following command,

react-native run-android

It starts a node process/JS server in another console panel, and you don't encounter this error. But, when you want to run another app, you must need to close that already running JS server console panel. And then execute the same command for another app from the power shell, that command will automatically start another new JS server for this app, and you won't encounter this error.

You don't need to close and reopen power shell for running another app, you need to close node console to run another app.


After have read all the above, I have found that there could be another reason for this.

In my case:

react-native-cli: 2.0.1

react-native: 0.60.4

and following structure:

enter image description here

First has to be noted that index.android is not been update in Android Studio when the build run by Metro builder( react-native run-android) so it has to be done manually. Also in Android studio does not "read" the

app.json(created by default together with index.js, that renamed index.android.js):

 {
    "name": "authApp",
    "displayName": "authApp"
 }

and so this like

(in my case)

import {authApp as appName} from './app.json';

cause the fact that android studio does not know what authApp refer to. I fix for the moment referring to the app name with its string name and not using that import from app.json:

AppRegistry.registerComponent('authApp', () => MyApp);

Modify MainActivity like this,

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

My solution is change module name in "AppDelegate.m"

from moduleName:@"AwesomeProject"

to moduleName:@"YourNewProjectName"


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);

I resolved this by changing the following in the app.json file. It appears the capital letter was throwing this error.

From:

{
  "name": "Nameofmyapp",
  ...
}

To:

{
  "name": "nameofmyapp",
  ...
}

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);

In my case there's this line in MainActivity.java which was missed when I used react-native-rename cli (from NPM)

protected String getMainComponentName() {
    return "AwesomeApp";
}

Obviously ya gotta rename it to your app's name.


My issue was that in AndroidManifest.xml and MainActivity.java package names were different. So in manifest I had package=com.companyName.appName and in activity package com.appName


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


All the given answers did not work for me.

I had another node process running in another terminal, i closed that command terminal and everything worked as expected.


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);

I had the same problem. I was using Windows for creating a react native app for android and was having the same error. Here's what worked.

  • Navigate to the folder ANDROID in your root.
  • Create a file with name : local.properties
  • Open it in editor and write :

sdk.dir = C:\Users\ USERNAME \AppData\Local\Android\sdk

  • Replace USERNAME with the name of your machine.

Save and run the app normally. That worked for me.


In my case i have got a different solution in case any one need

yarn remove react-native-material-dropdown

Install new packages react-native-material-dropdown-v2

yarn add react-native-material-dropdown-v2

Replace react-native-material-dropdown with react-native-material-dropdown-v2 in your code

e.g. import { Dropdown } from 'react-native-material-dropdown' to import { Dropdown } from 'react-native-material-dropdown-v2'

another thing ==========

  1. Open node_modules and then search for react-native-material-textfield open the file and go to src folder
  2. Under src you will see affix, helper, label folder - under each folder, there is an index.js
  3. open the index.js of the mentioned folders one by one (all 3 folders) and search for the text style: Animated.Text.propTypes.style, and replace it by style: Text.propTypes
  4. And import text form react-native like this import { Animated , Text} from 'react-native';

Non of the solutions worked for me. I had to kill the following process and re ran react-native run-android and it worked.

node ./local-cli/cli.js start


Please check your app.json file in project. if there has not line appKey then you must add it

{
  "expo": {
    "sdkVersion": "27.0.0",
    "appKey": "mydojo"
  },
  "name": "mydojo",
  "displayName": "mydojo"
}

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.


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to facebook

I am receiving warning in Facebook Application using PHP SDK React-Native: Application has not been registered error Can't Load URL: The domain of this URL isn't included in the app's domains Facebook OAuth "The domain of this URL isn't included in the app's domain" Facebook login message: "URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings." Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView` Open Facebook Page in Facebook App (if installed) on Android App not setup: This app is still in development mode IOS - How to segue programmatically using swift Get ALL User Friends Using Facebook Graph API - Android

Examples related to reactjs

Error: Node Sass version 5.0.0 is incompatible with ^4.0.0 TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app Template not provided using create-react-app How to resolve the error on 'react-native start' Element implicitly has an 'any' type because expression of type 'string' can't be used to index Invalid hook call. Hooks can only be called inside of the body of a function component How to style components using makeStyles and still have lifecycle methods in Material UI? React Hook "useState" is called in function "app" which is neither a React function component or a custom React Hook function How to fix missing dependency warning when using useEffect React Hook? Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release

Examples related to react-native

How to resolve the error on 'react-native start' React Native Error: ENOSPC: System limit for number of file watchers reached How to update core-js to core-js@3 dependency? Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 How can I force component to re-render with hooks in React? What is useState() in React? Getting all documents from one collection in Firestore ReactJS: Maximum update depth exceeded error React Native: JAVA_HOME is not set and no 'java' command could be found in your PATH