I start my React Native project with the following commands:
yarn start
yarn react-native run-android
It works when a real device connected to my PC and the project starts on my device. But it does not work with an Android Emulator.
When I try with an emulator:
yarn start
command shows usual outputs. No error, nothing. Seems to work correctlyyarn react-native run-android
also same. Build successful. No error or warning.adb devices
command shows my emulator correctly.But emulator does not start my project. I can see my project icon on the emulator. When I double click to my project, I just see a blank screen for one second or less and it closed again.
When i try to reload metro using r
command on terminal it says no apps connected.
I think the emulator builds the app but not connect to metro properly. I don't know why. I cannot see any error or warning messages.
I tried ./gradlew clean
and delete node_modules and install but it didn't work.
I also tried yarn start --port 8081
but it also didn't work.
EDIT: For testing purpose, I created a new project with `npx react-native init AwesomeProject' and it works on the emulator. So I think the problem is only about the other project.
SOLUTION: In my case it was because of Flipper version. When I changed it from 0.125 to 0.144 my project started on an android emulator properly.
Here is the link where i found the solution: react-native-issue-in-github