问题
I have recently started to convert my react native app and running on Expo so i could test this on my actual android device. I am getting this error above. I have since then running my app using the Expo XDE. I am also running on a windows machine.
The full error message is:
]1
I figured that this has something to do with my index.js, yet here it is
import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('projectTARA', () => 'App');
回答1:
The following solution worked:
AppRegistry.registerComponent('main',() => App);
Credits: Rishav Kumar
(Cannot you people just reply to mark as solve ?)
回答2:
The problem is you haven't opened your project in Android Studio. The previous project is running in android studio and you are running the latest one in emulator.
回答3:
I created a Project from "Doco", and save it with Practice. so write that line like that
AppRegistry.registerComponent('Practice', () => FixedDimensionsBasics);
then I get an error like in a question
So, I check on my Appdelegate.m file on ios folder and find that Project name is Project so I change that line with
AppRegistry.registerComponent('Project', () => FixedDimensionsBasics);
and my Error solved
so if you are using "Doco" then check that thing.
回答4:
I came across this issue because I had previously run a React project that was not fully shut down. To fix this, I could have restarted my computer. But I chose to do this instead: (Using MacOS, should work with Linux as well, for Windows you would likely need to use Task Manager or similar):
- Open terminal
- Find the program that is using port 8081 by typing "lsof -i :8081". (Note this is LSOF in lowercase)
- Look at the process ID (under the PID column)
- Kill the process by typing "kill -9 PID" (where PID is the process ID number you found in step 3).
After killing the process you should be able to run your react-native project.
来源:https://stackoverflow.com/questions/49410115/application-main-has-not-been-registered