18
votes

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)

10
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
Poderia me ajudar com esse Erro Por Favor: stackoverflow.com/questions/57077095/… - Morgana Oliveira
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. - Abhinav Saxena

10 Answers

31
votes

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)

9
votes

Use this:

react-native run-android --no-jetifier

3
votes

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

2
votes

react-native run-android --no-jetifier

and again start server

react-native start

1
votes

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

0
votes

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
votes

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

0
votes

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 // 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.

0
votes

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

npm install --save-dev jetifier
-1
votes

Maybe you are in the Android folder, you need to go back to your root folder then try the following code,

npx react-native run-android