6

I am trying to run my react native app on my device . So I am running react-native start everything looks fine. enter image description here

and when running react-native run-android I get this error enter image description here

otherwise, I get this error in my device

enter image description here

Noam Hacker
  • 4,671
  • 7
  • 34
  • 55
Sihem Hcine
  • 1,089
  • 5
  • 24
  • 40
  • check your index.andorid.js. check the line AppRegistry.registerComponent .check if u have properly registered the class. Also make sure u are on the correct project folder – Victor Jul 05 '17 at 11:33
  • i put class 'proj extends Component ' and for the app registery 'AppRegistry.registerComponent('proj', () => proj)' . ps : my prject's name is proj – Sihem Hcine Jul 05 '17 at 11:36
  • Please post the code index.andorid.js – Victor Jul 05 '17 at 11:39
  • `import React, { Component } from 'react' import { AppRegistry, Text, View } from 'react-native' class proj extends Component { render() { return ( Welcome to PutainDeBiere! ) } } AppRegistry.registerComponent('proj', () => proj)` – Sihem Hcine Jul 05 '17 at 11:47
  • use the code below – Victor Jul 05 '17 at 11:48

3 Answers3

10

My issue was the name I gave the project differed from the name that was being registered in AppRegistry

AppRegistry.registerComponent('proj', () => proj)

proj needs to be the same as the name of the project in the gradle and config files.

Harry Moreno
  • 10,231
  • 7
  • 64
  • 116
1

You need to export the class. Use the code below

 import React, { Component } from 'react' 
import { AppRegistry, Text, View } from 'react-native'
export default class proj extends Component {
 render() { 
return ( 
<View style={styles.container}> <Text > Welcome to PutainDeBiere! </Text> </View> ) 
} 
}
 AppRegistry.registerComponent('proj', () => proj)
Victor
  • 4,171
  • 1
  • 29
  • 37
  • check your index.ios.js the following line should be same in both if not use the one in ios file.. the first parameter is the name of the project .. it should be correct. AppRegistry.registerComponent('proj', () => proj) .. if everything fails shutdown everything and restart – Victor Jul 05 '17 at 11:56
  • i have the same code in index.ios.js as in index.android.js. I get the same error – Sihem Hcine Jul 05 '17 at 13:03
  • ps : i have problemwhen running npm installin the project – Sihem Hcine Jul 06 '17 at 07:52
  • @SihemHcine try sudo rm -rf node_modules then npm install – Victor Jul 06 '17 at 08:34
0

Delete / uninstall first the APP installed and then do a clean install of it and see if it works.

Brunaine
  • 1,178
  • 2
  • 16
  • 24
  • did you move the files to another folder or something? it can cause problems if the xcode files and others doesn't have the same name has the project – Brunaine Jul 05 '17 at 13:32
  • try on the terminal: `lsof -i :8081` and use the PID of the several things that appear on the terminal, `kill -9 PID`, when there's nothing try to run the APP again – Brunaine Jul 05 '17 at 13:37
  • i try lsof -i :8081 , nothing is appeared but i get the same error :( – Sihem Hcine Jul 05 '17 at 13:42
  • nothing appears? i should appear at least 1 , do react-native start on one terminal and react-native start on another, and then try the lsof command to see if it shows something, don't ever close the react native start terminal – Brunaine Jul 05 '17 at 13:43
  • the same thing ,i wonder if the the problem is from node version , it s 4.x – Sihem Hcine Jul 06 '17 at 08:26
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/148476/discussion-between-sihem-hcine-and-brunaine). – Sihem Hcine Jul 06 '17 at 08:43