I had an issue in my React-Native project which was working fine earlier but suddenly it stopped working. Whenever I used the command:
react-native run-android
I was getting an error:
Android project not found. Maybe run react-native android first?
I tried running:
react-native android
But it said:
Unrecognized command 'android' Run react-native --help to see list of all available commands
After trying:
D:\ProjectRoot\ReactNativeProjects\AwesomeProject>react-native eject
The error returned was:
Scanning folders for symlinks in D:\ProjectRoot\ReactNativeProjects\AwesomeProject\node_modules (48ms) App
name
must be defined in theapp.json
config file to define the project name. It must not contain any spaces or dashes.
This is the app.json file:
{ "expo": { "name": "AwesomeProject", "description": "A very interesting project.", "slug": "AwesomeProject", "privacy": "public", "sdkVersion": "30.0.0", "platforms": ["ios", "android"], "ios": { "supportsTablet": true }, "android": { "package": "com.project.first" }, "version": "1.0.0", "orientation": "portrait", "icon": "./assets/images/icon.png", "splash": { "image": "./assets/images/splash.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "updates": { "fallbackToCacheTimeout": 0 }, "assetBundlePatterns": [ "**/*" ] } }
Running your React Native applicationInstall the Expo Go app on your iOS or Android phone and connect to the same wireless network as your computer. On Android, use the Expo Go app to scan the QR code from your terminal to open your project. On iOS, use the built-in QR code scanner of the default iOS Camera app.
I raised this question and answered myself as I thought it will help others who are facing similar issue. I struggled a lot to find out the real reason behind it as the error shown in terminal was not precise.
To resolve the issue please upgrade the react-native package.
Go to the Project root.
Upgrade the React native package in the Command Prompt by typing :
react-native upgrade
.
Then Accept to update all the Files by typing y (Yes)
in the Command Prompt.
Reference: https://github.com/facebook/react-native/issues/9312
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With