29

I tried to run react-native run-android and I got this error.

info Running jetifier to migrate libraries to AndroidX. You can disable 
    it using "--no-jetifier" flag.
    error Failed to run jetifier. Run CLI with --verbose flag for more details.
    Error: spawnSync C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\jetifier\bin\jetify ENOENT
    at Object.spawnSync (internal/child_process.js:1002:20)
    at spawnSync (child_process.js:614:24)
    at execFileSync (child_process.js:642:13)
    at Object.runAndroid [as func] (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:101:41)
    at Command.handleAction (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\@react-native-community\cli\build\cliEntry.js:160:21)
    at Command.listener (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\commander\index.js:315:8)
    at Command.emit (events.js:198:13)
    at Command.parseArgs (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\commander\index.js:651:12)
    at Command.parse (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\commander\index.js:474:21)
    at setupAndRun (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\@react-native-community\cli\build\cliEntry.js:210:24)

3
  • Are you wanting to include Android X? If so, you'll need to run jetifier. Could you comment on whether you want to Android X-ify your project and I'll provide the answer.
    – JRK
    Jul 16, 2019 at 8:29
  • Please check your gradlew batch file. It should have executible flag on if you are using Mac or Linux Ubantu. It was the only thing that prevented me and gave the error above, all the time. When you sync, the property seldom resets. Feb 19, 2020 at 13:12
  • 1
    make sure you are not in android subfolder I had jetifier error when accidentally running from there
    – pera
    Nov 17, 2021 at 22:02

12 Answers 12

47

Use this :

step 1: add these two lines in gradlew.properties Visit for complete guideline

android.useAndroidX=true
android.enableJetifier=true

step 2: use these commands

First of all remove node_modules folder and reinstall it using

npm install 

or

yarn

and then

npm install --save-dev jetifier 
npx jetify  
npx react-native run-android 

Call

npx jetify

every time when (your dependencies update or every time you install node_modules you have to jetify again)

1
  • Command run-android unrecognized. Make sure that you have run npm install and that you are inside a react-native project. Aug 22, 2020 at 1:27
41

When I was getting this error I noticed that I'm not in the main project folder I was inside the cd android folder. So I just cd .. it and it worked.

3
  • 1
    Thank you, that actually worked for me!
    – myrs
    Jan 3, 2022 at 21:59
  • This is the solution Feb 16, 2022 at 8:27
  • 2
    I didn't notice that until read your answer. Thanks a log
    – Canh
    May 26, 2022 at 4:50
15

If you run npx react-native run-android in android folder. That error will happen. You need to run-android in the root directory.

2
  • Thanks to make me reallize how silly I am:)
    – amerw
    Jul 14, 2022 at 3:20
  • dude you are life saver i am about to follow the most voted answer
    – mirsahib
    Sep 13, 2022 at 15:24
12

Use this:

react-native run-android --no-jetifier

3
  • What do you suggest if jetifier needed ? Stack trace already say that You can disable it using "--no-jetifier" flag.
    – Hamit Enes
    Jul 16, 2019 at 7:35
  • This issue discussing on link
    – Hamit Enes
    Jul 16, 2019 at 7:43
  • I dont want to use --no-jetifier ie. I want the jetifier
    – NduJay
    Jul 16, 2019 at 20:34
5

I'm using yarn so I had to use

yarn react-native run-android --variant=release

(Not npx)

Also to run in the simulator (not on a device) I had to install some extra stuff in Android Studio, see https://stackoverflow.com/a/64942777/3469524

3

react-native run-android --no-jetifier

and again start server

react-native start

2

Mostly it happened by cache, metro server closed or already generated package in android folder. check jetifier is enabled in gradle.proporties

android.useAndroidX = true
android.enableJetifier = true
  1. First close your metro server terminal window and run $ yarn android // this is almost solve your issue otherwise follow the below steps

  2. Then run

    $ cd android && ./gradlew clean

  3. Clean the cache and build folders - generated & intermediates

    $ ./gradlew cleanBuildCache

  4. Create the debug apk

    $ ./gradlew AssembleDebug //output: Build successful

    then check your apk output folder.

  5. Run the react native package

    $ yarn android || npx react-native run-android

Now it's working fine.

1

The issue is in React Native CLI v2.6.1

Use Below steps to resolve the issue:

  • If you use lock files (yarn.lock or package-lock.json) - find the @react-native-community/cli entry, remove it, run yarn install / npm install once again.

  • If you don't use lock files – remove node_modules and run yarn install / npm install again.

  • Run yarn list @react-native-community/cli or npm list @react-native-community/cli and verify you're on the latest version (v2.6.2).

  • Run react-native run-android

1

Just run the following command in the project's directory:

npm install --save-dev jetifier
1

Check current directory set to project root and then run npx react-native run-android

0

Just change from "C" directory to any other directory and then install/run starting from here "npm install -g react-native-cli" . Then create new project "react-native init AwesomeProject " use Yarn to install dependencies fast. It worked for me.

0

I use this react-native run-android --no-jetifier worked me

Not the answer you're looking for? Browse other questions tagged or ask your own question.