React-native: [cli] Command `run-android` unrecognized.

Created on 20 Sep 2015  路  34Comments  路  Source: facebook/react-native

I'm following the quick start guide to create a RN app, but got the error message:

Command `run-android` unrecognized. Did you mean to run this inside a react-native project?

and the command react-native android is also unrecognized.

Environment:

  • node v4.0.0 (npm v2.14.2)
  • RN v0.11.0
Locked

Most helpful comment

Had the same issue, it turned out I did not have /node_modules directory inside.
Runningnpm install solved the problem.

All 34 comments

thank you react-native android command was fine

same issues happens to me also

copy directory "node_modules" to my project fixed.
you can find "node_modules" in demo project.

so i guess we should run "react-native init" or "react-native android" first.

Did you change to your app's folder? Just updated the Getting Started guide to make this clearer:
https://github.com/facebook/react-native/blob/master/docs/GettingStarted.md

i don't think what you have updated is useful to this issue
https://github.com/facebook/react-native/commit/a0ccebc460b42ae2b2517f2118ca0cbfe00d6e98#diff-c427a522f4ea08a4c045a518ac721ce9

Thanks @pcqpcq, changing directory did fix my problem.

If you are using a version of react-native-cli less than 0.12, any error will get swallowed and you'll see the error "Command run-android unrecognized", regardless of what the actual error is. In my case, I was running the command from the correct directory, but lodash had somehow gotten into a corrupt state. Doing npm uninstall lodash and npm install lodash fixed the problem for me.

The react-native-cli in v0.12.0-rc will not swallow errors: https://github.com/facebook/react-native/commit/373c8777f6bad3a935089bd4c59bf2e15896de63.

What I did was hack my installed version of react-native-cli (found using which react-native) so that the error is logged to the console.

Command run-android unrecognized. Did you mean to run this inside a react-native project?
Getting same issue i have tried all possible stuff but still doesn't working even android command also not working

Im getting same thing... it's on an existing project that I just did a fresh npm install on. It worked before, so maybe an updated package broke it?

Had the same issue, it turned out I did not have /node_modules directory inside.
Runningnpm install solved the problem.

miss node_modules directory

I am learning react native and Trying to run this project https://github.com/FaridSafi/react-native-gifted-messenger

but all the time getting the error

gathole$ react-native run-android
Command `run-android` unrecognized. Did you mean to run this inside a react-native project?

Can someone please help me out to run this project???

yep "npm install" fix the problem

same issues happens to me also

@vhrv Did you try 'npm install' and after that 'react-native run-android' ? Same issues for me and this, fix the problem. Maybe be patient, because 'npm install' was a bit long !

For Linux Users

Your app is not getting the path of android-sdk, so If you are using linux (ubuntu), than you need to add a file named "local.properties" and save it inside the android folder, which is created inside your app folder.

You need to add below line inside local.properties file, which is the path of your android-sdk lies inside your system inside system in order to run the app.

sdk.dir=/opt/android-sdk/

save and rerun the command _react-native run-android_

OR

you can open terminal, type

sudo nano ~/.bashrc

and paste the below path at the end of the file

export ANDROID_HOME="/opt/android-sdk/"

and _restart your computer_ and run again _react-native run-android_ after that.

Note:- If you put set path in .bashrc file, then you don't even need to create local.properties file.

I was receiving the error:
Unrecognized command 'run-andriod'

I followed this guide but I put the line:

# If you installed the SDK via Homebrew, otherwise ~/Library/Android/sdk
export ANDROID_HOME=/usr/local/opt/android-sdk

in my .bash-profile file. When I put it in .bashrc file (and restarted terminal) the command react-native run-andriod worked.

I am was outside the project while running 'run-android' command. I just navigated to to project by below command:
cd AwesomPoject

And then run the command. It worked like a charm.

Are you sure that the correct directory? Look at directory of project.

So, I still can't get it to run... I'm trying to bootstrap it from a Docker image https://github.com/MaximeD/docker-react-native#get-image

dev@kauai:~/app$ echo $ANDROID_HOME 
/usr/local/android-sdk-linux

dev@kauai:~/app$ react-native run-android
Scanning 2 folders for symlinks in /home/dev/app/node_modules (0ms)
Android project not found. Maybe run react-native android first?
dev@kauai:~/app$ react-native android    
Scanning 2 folders for symlinks in /home/dev/app/node_modules (0ms)

  Unrecognized command 'android'
  Run react-native --help to see list of all available commands

However, I do have the command android...

dev@kauai:~/app$ which android
/usr/local/android-sdk-linux/tools/android

dev@kauai:~/app$ android version
Error: Expected verb after global parameters but found 'version' instead.

       Usage:
       android [global options] action [action options]
       Global options:
  -h --help       : Help on a specific command.
  -v --verbose    : Verbose mode, shows errors, warnings and all messages.
     --clear-cache: Clear the SDK Manager repository manifest cache.
  -s --silent     : Silent mode, shows errors only.
...
...

ok if you have configured your project or machine with yarn and used npm install in your project than your project will break with the same error.
solution - delete node_module flder
than use yarn install followed by react-native run-android

@manjeets12 exactly, my issue is that I had used npm install.

Deleting the node_module folder and running yarn install fixed the error for me.

Had the same issue but then i came across this solution to run yarn add react-native-cli.

use yarn instead of npm

using just Yarn command fixes it but unfortunately i have to do it always when i run the emulator and it takes time!

@doukasd Thank you

I am the same issue that all...

I'm on the correct directory (root of my project, the node_modules folder is here).
I added the export in my bashrc
I deleted the node_modules folder and I used yarn install and run "react-native run-android" and "react-native android" ...

Delete node_modules folder and run these two commands worked for me!!
yarn install
yarn add react-native-cli

@doukasd @Mardii-D-King thank you!

I had the same issue when i installed react-native-action-bar, maybe the installed package broke it.
Running npm install solved the problem.

navigate the proper path to run this command - *react-native run-android *

npm uninstall lodash and npm install lodash fixed the problem for me

make sure about the android studio or other emulator be opened, when execute this common:
react-native run-android

This is preposterous. react-native cannot call itself a mature project when it uninstalls itself and mutates into corrupt state.

You may also be in the wrong directory. Be sure you're in main directory.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grabbou picture grabbou  路  3Comments

WG-Com picture WG-Com  路  3Comments

phongyewtong picture phongyewtong  路  3Comments

josev55 picture josev55  路  3Comments

lazywei picture lazywei  路  3Comments