I get this strange error in VScode when I try to execute the command React-native run-android in the terminal.
Also ran react-native doctor and all green checkmarks for Node,yarn, android_home, and android sdk 0 errors
Not sure how to fix these issues as I have tried all suggestions in previous threads. Anyone have this issue that could assist? This is a windows machine.
Error Image
1.first Gradle needed to connect to the internet.
2.cd android
./gradlew clean
./gradlew wrapper
./gradlew -v // to download the new version
3.project app-level build.gradle file:
update version this
com.google.firebase:firebase-analytics
and this
com.google.gms:google-services
When I run npx react-native run-android, I got this error:
Cannot find module '#react-native-community/cli'
I run npm list #react-native-community/cli and got the following version information:
└─┬ react-native#0.61.5
└── #react-native-community/cli#3.0.4
Anyone has a clue how I can solve the issue?
This has happened to me in the past. Doing a clean install of the app and recloning the repository worked for me.
Remove node_modules folder and run npm install
From what it seems you need to install react-native-community, try after installing that
npm install -g react-native-cli
Hope it helps
react-native run-android shows
env: sh\r: No such file or directory
try to clean and rebuild your project
react-native start --reset-cache
cd android
gradlew clean
gradlew assembleDebug
or you can simply reinstall npm modues
See if you've done this.
npm install -g react-native-cli
react-native init yourproject
cd yourproject && react-native run-android
I'm using react-native 0.43.3 on OSX.
I tried to running app on Android and get message
react-native run-android
Scanning 568 folders for symlinks in /Users/ruci.k/project/mayacrew/supermembers/supermembers/node_modules (5ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
./gradlew installDebug gave me some errors and fixed it all.
Finally build get successed and app is working on Android device.
But react-native run-android command still not work.
Only ./gradlew installDebug command work.
Is there anything can I check to use react-native run-android command?
I can't understand how could it happened.
Running
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
worked for me
Run the following command
chmod 755 android/gradlew
inside your app root folder
then run
react-native run-android
After you create your react native app ,try
sudo chmod -R 777 node-modules
sudo chmod -R 777 android
export ANDROID_HOME=~/Library/Android/sdk
now run
react-native run-android
Try removing android,ios folders and then do react-native upgrade then try again react-native run-android After that if you get an error like
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
then create a file named local.properties inside the folder
android
and insert the following line sdk.dir =/path/to/Android/Sdk After this everything should be fine
Note: If you have made some changes in android/ios folder please keep its backup before removing the folders
cd android && sudo ./gradlew clean
This worked for me. Try it out and let me know if it helps folks
I have faced the same issue when I have imported the project from the GitHub.
Follow the below steps to run your react-native project in the Android device from the MAC OS
Remove the 'node_modules' folder from the root project.
Run the below command in the project root folder.
npm install
Move to the android folder in the project root folder.
cd android
Run the following commands one after another to give permissions to gradlew file.
chmod +x ./gradlew
xattr -l ./gradlew
xattr -d com.apple.quarantine ./gradlew
Now, come back to project root folder and run the project in android device.
react-native run-android
Now you can see the launched application on your connected Android device/emulator.
In Ubuntu, I have used this command and it worked for me:
sudo react-native run-android
I had the same issue, and just opened the project in android studio, and that's all. Solved!
this issue come from two reasons
1- Permission issue
How to Fix it
sudo react-native run-android
Or
chmod 755 android/gradlew
2- Mismatch java version with Gradle
make sure you are using Java 8 as $JAVA_HOME environment variable
depending on which terminal you are using to run your code at
For zsh shell, export $JAVA_HOME at ~/.zshenv or ~/.zshrc.
For bash shell, export $JAVA_HOME at ~/.bash_profile or ~/.bashrc.
get installed JDK by this command
/usr/libexec/java_home -V
example for using zsh
vi ~/.zshrc
// paste the java export inside it
export JAVA_HOME="JDK_8_Path_from_previous command"
to save your change
:x
make sure your changes applied
source ~/.zshrc
now for testing
echo $JAVA_HOME
You must change your build.gradle:
compileSdkVersion 28
buildToolsVersion "28.0.2"
minSdkVersion 16
targetSdkVersion 27
and add this line:
implementation "com.android.support:appcompat-v7:28.0.0"
Check whether your emulator is connected or not:
set ANDROID_HOME path: E:\android-sdk-windows
set path D:C:\Program Files\nodejs;C:\Program Files\Java\jdk1.8.0_111\bin;E:\android-sdk-windows\platform-tools
go to folder android in terminal
gradlew clean
run react-native run-android
maybe install watchman?
https://github.com/facebook/react-native/issues/10056
Otherwise, for me I actually use 'npm start' inside of the folder. npm will know to run the right command to start react native because it's in a react native directory.
So what i did was to download this jar file from: 1: https://drive.google.com/file/d/1MHSJx-_0RHRzlrXBLAePKeWKQteke0Um/view?usp=sharing and placed it inside android/gradle/wrapper then i went back to the project directory and did npm install i then changed directory to android by doing: cd android then i ran the following commands
chmod +x ./gradlew
xattr -l ./gradlew
Now i went back to the project directory and ran react-native run-android
Go to C:\Users\ [username]
Rename or delete ".gradle"
Then run "react-native run-android"
So here are the three solution for this bug , from which one will most probably solve your issue :
1: Adding local.properties file in your android folder
https://stackoverflow.com/questions/32634352/react-native-android-build-failed-sdk-location-not-found
2: Try deleting .gradle file and then build (react-native run-android)
3: Might be possible that under SDK tools NDK(side by side) and CMake are not installed .
Steps for the same is
Android Studio which include direction for opening sdk manager
Open android folder in Android Studio
Click on the SDK Manager (which is at the third position from the top left )
After opening SDK manager you have to go to SDK Tools Installation image for NDK and CMake
Under SDK Tools select NDK(side by side) and CMake and press the okay button and let the installation complete .
After the close the Android Studio and react-native run-android.
1 . you should have space in your phone
2 . developer option on
3 . USB debugging option also on
4 . check "adb devices" devices is connected or not
I have to perform these steps to get it running.
First install dos2unix
Run dos2unix ./gradlew inside android folder
then run ./gradlew clean
at last run react-native run-android.
For me, this had to do with running low on RAM om my Mac.
in gradle.properties put -XX:MaxPermSize=4096
for example like this:
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m
After that, it runs again.
What worked for me is,
Uninstalling the previous installed app version on the emulator device, and running react-native run-android after.
Check the error messages carefully. It will give a clue to what went wrong. In my case, after installing expo in my react-native project, the MainApplication.java got corrupted. I made a comparison with the a backup (you can check an earlier working commit), then removed the erroring lines.
After this, it worked.
When starting android project with React-Native it is giving this error:
React-Native Command run-android unrecognized.Did you mean to run this inside a react-native project?
You can try to do npm install before react-native run-android
First we have to install react-native then upgrade packages if you need and run android.
npm install --save react-native#latest
react-native upgrade
react-native run-android
A lot of developers fail to mention the crucial point,that certain commands require you to be a particular directory. In this case, to "react-native run-android", you have to be in your project directory!
Command run-android unrecognized. Make sure that you have run npm install and that you are inside a react-native project.
I faced this issue, the problem is we need to navigate to or project folder.
example: I created the project in "MyApps" with app name "DemoApp" in D drive
the command line root should be like this:
D:\MyApps\DemoApp>react-native run-android
now it will run with out any issue.
The problem is your android related info is presents inside the app not t=in the main directory.
I was facing the same problem and the above solutions did not work. Try using:
yarn add react-native-cli
First of all please see if devices/emulator is attached and working by following command
adb devices
there should be some devices showing connected
it is better to restart/reconnect you emulator/device and then try to run application again
if not working you can also try
npm install
You need to make sure that you are inside the project like cd AwesomeProject and do npm i and after that execute npx react-native run-android
In my case the problem was that I was in the android folder of my project due to this command cd android && ./gradlew assembleRelease.So the solution was to cd ../ and come to root of project and then running this command
react-native run-android --variant=release
ran fine.
For me the issue was I was not inside the project directory AwesomeProject( Project that I created using this command :
react-native init AwesomeProject )
I got it fixed after adding Android sdk-tools to PATH, and restarting VSCode/Terminal.
/Users/<username>/Library/Android/sdk/build-tools
Earlier my path set to
/Users/<username>/Library/Android/sdk
1.make sure java jdk installed
2.make sure npm installed in your project root folder
3.this works for me