React-native: Error running default application

Created on 30 Mar 2015  Â·  12Comments  Â·  Source: facebook/react-native

When I follow the Getting Started instructions, I am unable to run the default application. I have not made any modifications to the generated code. The start-up screen runs and then I see a red screen with the following error message:

Invariant Violation: Application AwesomeProject has not been registered
Object.AppRegistry.runApplication
AppRegistry.js:75

jsCall
MessageQueue.js:46

MessageQueueMixin._callFunction
MessageQueue.js:293

Object.ErrorUtils.applyWithGuard
error-guard.js:30

guardReturn
MessageQueue.js:95

MessageQueueMixin._callFunctionReturnFlu...
MessageQueue.js:302

messageHandlers.executeJSCall:method:ar...
require.js:51

WebSocket.ws.onmessage
require.js:77

The following stack trace is provided in the Chrome debug console:

 stack: 
  Object.AppRegistry.runApplication                         index.ios.bundle:33854
  jsCall                                                    index.ios.bundle:7215
  MessageQueueMixin._callFunction                           index.ios.bundle:7462
  Object.ErrorUtils.applyWithGuard                          index.ios.bundle:877
  guardReturn                                               index.ios.bundle:7264
  MessageQueueMixin.callFunctionReturnFlushedQueue          index.ios.bundle:7471
  messageHandlers.executeJSCall:method:arguments:callback:  debugger-ui:54
  WebSocket.ws.onmessage                                    debugger-ui:80
 URL: undefined
 line: undefined
 message: Invariant Violation: Application AwesomeProject has not been registered.index.ios.bundle:6901 handleException
Locked

Most helpful comment

i think the issue is due to React Packager, if you have react packager already running for a project and then you try to run another react project without closing the packager you will get this issue.

Steps to reproduce :
=> run any react app using react-native run-android. Since this is first time react packager will be started.
=> once you see your app in emulator go to any other react app on terminal and run that app. Since react packager is already running it will reuse it and will cause this issue.

All 12 comments

Can you post your entire index.ios.js here?

This is the same issue as this one on Stack Overflow that seems to have multiple potential solutions:

http://stackoverflow.com/questions/29287987/

Suggest giving each of those a go and commenting/voting on the one (if any) that works for you.

None of the suggestions on Stack Overflow made any difference. This is a brand new app generated by react-native with no modifications. I'll include the entire file below to be thorough:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';

var React = require('react-native');
var {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} = React;

var AwesomeProject = React.createClass({
  render: function() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js{'\n'}
          Press Cmd+R to reload
        </Text>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
  },
});

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

Do you see any errors reported by the packager? It looks like that registerCompoent is never run. If you curl the output, do you see anything suspicious?

Can you open the bundle in your browser and paste it somewhere?
http://localhost:8081/index.ios.runModule.bundle

This problem eventually went away, and I haven't been able to replicate it for several days. Maybe it was a networking quirk or something. I'll close it for now and re-submit if it pops up again.

Hi, everyone, I just got this error because I wrote the wrong StyleSheet

You can try this:

StyleSheet.create({
  cover: {
    'display': 'absolute'
  }
});

The correct one is {position: 'absolute'}. But the error makes me confused:

image

Maybe the error message should be improved when there is something wrong in the StyleSheet

(by the way: I'm using the latest xcode 6.3.2 and 6.0 RC of react native in the osx 10.11)

Because use es6 in the bottom of scripts, so create a file called .babelrc and add

 {
"whitelist":[
"es6.modules"
]
}

in this file and then re-run . Bingo!

I tried to run project by clicking build button on XCode and i got the same error message.
Then i run the project via command line with "react-native run-ios" and it worked.
Any idea?

try stop your simulator first and then reload js

i am not getting any solution yet. :-(

i think the issue is due to React Packager, if you have react packager already running for a project and then you try to run another react project without closing the packager you will get this issue.

Steps to reproduce :
=> run any react app using react-native run-android. Since this is first time react packager will be started.
=> once you see your app in emulator go to any other react app on terminal and run that app. Since react packager is already running it will reuse it and will cause this issue.

Was this page helpful?
0 / 5 - 0 ratings