"Invariant Violation: Application AwesomeProject has not been registered" When building for iOS device with static jsbundle

IosReact Native

Ios Problem Overview


First off, I don't know react, but I figured deploying to an iOS device instead of the simulator wouldn't be too difficult to do with the docs. They were a bit sparse but I got somewhere and now I'm stuck. I created a main.jsbundle and added it to the Xcode project and uncommented the line in AppDelegate.m.

When I deploy it I get this error:

2015-03-26 16:13:08.538 AwesomeProject[4753:2477032] >
  RCTJSLog> "Running application "AwesomeProject" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF"
2015-03-26 16:13:08.547 AwesomeProject[4753:2477032] >
  RCTJSLog> "Error: 
 stack: 
  runApplication                  main.jsbundle:33769
  jsCall                          main.jsbundle:7157
  _callFunction                   main.jsbundle:7404
  applyWithGuard                  main.jsbundle:877
  guardReturn                     main.jsbundle:7206
  callFunctionReturnFlushedQueue  main.jsbundle:7413
 URL: file:///private/var/mobile/Containers/Bundle/Application/DBC0DAF4-B568-4CF5-B156-9EFEE4E7FF4A/AwesomeProject.app/main.jsbundle
 line: 1536
 message: Invariant Violation: Application AwesomeProject has not been registered."
2015-03-26 16:13:08.723 AwesomeProject[4753:2477032] >
  RCTJSLog> "#CLOWNTOWN (error while displaying error): Network request failed"

Ios Solutions


Solution 1 - Ios

I'm pretty sure @krazyeom's fix has nothing to do with this error. In my case, I fixed this by quitting the terminal that was running from a previous test app I had run. It seems the terminal was confused and was still hooked to a process whose project was no longer loaded in XCode. Try the following:

  1. Shut the Terminal spawned by React Native.
  2. Shut down XCode completely (may not be necessary).
  3. Re-open everything and re-run.

Solution 2 - Ios

Your problem shouldn't have anything to do with the console, if you properly bundled your javascript into the ios app it wont be trying to talk to dev server, it'll just get the javascript from the bundle.

From the error message I'd guess that you might have renamed your main component. Be sure that in your main index.js the 'AppName' you pass into the

AppRegistry.registerComponent('AppName' /* <- */, ... )

matches with the @"AppName" on your AppDelegate.m on the call for

[[RCTRootView alloc] initWithBundleUrl:...
                            moduleName:@"AppName" // <-
                         launchOptions:...

Solution 3 - Ios

It is because the react-native server is still watching the old one. You need to shut the server down first.

You could just kill the process.

In terminal

ps aux | grep react

Kill or pkill the process and then

npm start

Solution 4 - Ios

AppRegistry defines the entry point to the application and provides the root component.

Your first param doesn't match your project name.

AppRegistry.registerComponent('AwesomeProject', () => YourMainComponent);

First param of registerComponent has to be your project name, second param is anonymous function that returns your root react component.

If first param doesn't match xcode project name, you get that error that your application has not been registered.

In case you don't have AppRegistry in the scope you can call it like this React.AppRegistry.registerComponent or you can assign it to the AppRegistry var

var {
  AppRegistry
} = React;

Solution 5 - Ios

I got this issue after renaming the project name and a couple of files. to solve it just make sure that the name of the app is the same in index.js app.json, MainActivity.java and AppDelegate.m.

app.json

{ "name": "MyNewApp", "displayName": "MyNewApp" }

index.js

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

MainActivity.java

`@Override protected String getMainComponentName() {
return "MyNewApp"; }

Solution 6 - Ios

I had the same issue. I solved it by giving the same name to both AppDelegate's moduleName and AppRegistry.registerComponent

If you are running the app with $ react-native run-ios you will need to rename the moduleName field in ./ios/[project name]/AppDelegate.m to match the new name of the project. Refresh the phone simulator and it should show the new code.

Solution 7 - Ios

AppRegistry.registerComponent('abc',() => ***); 

the 'abc' must be the same as the moduleName:@'abc' in the file name AppDelegate.m

Solution 8 - Ios

Did you change the name of the app that you're registering? I started the app with the name 'tricky', then later changed the name in this line:

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

and I started getting the invariant error.

Solution 9 - Ios

This is a lot later, but I was still experiencing this same issue. I tried to follow the restart everything path but it didn't fix it. What ended up fixing this for me was making sure my app.json 'name' field (used the same value in the 'displayName' field) matched the 'moduleName' field in my RCTRootView. matched those up and everything was groovy. Hope this helps someone out there.

Solution 10 - Ios

I am not fan of closing down everything so I dig this further.

All I had to do is in my terminal window, I ran this command:

../lala/node_modules/react-native/packager/launchPackager.command ; exit; 

My project name was "lala" , so find that there is node_modules in your project too.

replace lala with your project name it should work.

If there is an error says port is already in use:

 ERROR  Packager can't listen on port 8081

Then you have two choices:

  • Kill already running program.
  • Or Change the port by going into : ../lala/node_modules/react-native/packager/packager.js then find your port number, example 8081, and replace with the port number that is not in use.

> var options = parseCommandLine([{ > command: 'port', > default: 8082, > }, {

Save this file and then run the above command again.

This way I can run multiple react(ors).

Solution 11 - Ios

Got the same error, restarting everything including the xcode and terminal worked for me.

Solution 12 - Ios

Reference a nameless person.

it works for me.


I had almost the same problem you currently have a few days ago. For me it was a real device.

From all my research, the solution that worked for me is the following:

  1. When you launch your app by typing react-native run-android, the error appears.
  2. So, reach your directory containing "adb.exe" ( for me it was
    C:\Users\username\AppData\Local\Android\Sdk\platform-tools\ )
  3. open a terminal from here. And type adb reverse tcp:8081 tcp:8081
  4. Then, by reloading the app on the phone, it should work.

Solution 13 - Ios

I got the similar message in the console.

message: Invariant Violation: Application AwesomeProject has not been registered."

I just added REACT_EDITOR=atom on ~/.bashrc file.

Solution 14 - Ios

Usually, this Error nowadays has to do with the different versions of react-navigation being used.

If you are using react-navigation 4.0

"react-navigation": "^4.1.0",

you have to make sure you are importing the right elements from the right places

in your app.js

import { createAppContainer, createSwitchNavigator } from 'react-navigation'
import { createStackNavigator } from 'react-navigation-stack'
import { createBottomTabNavigator } from 'react-navigation-tabs'

This has helped me resolved the issue.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncmpView Question on Stackoverflow
Solution 1 - IosxanadontView Answer on Stackoverflow
Solution 2 - IostadeuzagalloView Answer on Stackoverflow
Solution 3 - IosNickwanhereView Answer on Stackoverflow
Solution 4 - IosalucicView Answer on Stackoverflow
Solution 5 - IossutuioncodeView Answer on Stackoverflow
Solution 6 - IosDawanView Answer on Stackoverflow
Solution 7 - Ioswickey liangView Answer on Stackoverflow
Solution 8 - IosMarques WoodsonView Answer on Stackoverflow
Solution 9 - IosinsaineyesayView Answer on Stackoverflow
Solution 10 - IoscodebasedView Answer on Stackoverflow
Solution 11 - IosSimarView Answer on Stackoverflow
Solution 12 - IosJerry ChouView Answer on Stackoverflow
Solution 13 - IoskrazyeomView Answer on Stackoverflow
Solution 14 - IosJonathan SanchezView Answer on Stackoverflow