我试图运行react native run android,但我遇到了这个错误.

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)

推荐答案

使用这个:

第一步:在gradlew中添加这两行.物业Visit f或 complete guideline

android.useAndroidX=true
android.enableJetifier=true

第2步:使用这些命令

首先,删除node_modules文件夹并使用重新安装

npm install 

yarn

然后

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

呼叫

npx jetify

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

React-native相关问答推荐

需要以前的props和state回调的静态 getDerivedStateFromProps?

_react2.default.PropTypes.function 未定义

错误发生意外错误:https://registry.yarnpkg.com/react-native-template-react-native-template-typescript:未找到

请求无法完成,因为您已超出配额

如何在 React Native 中创建和保存 CSV 文件?

什么时候适合在 React 中使用构造函数?

检索元素的父项时出错:找不到与给定名称android:TextAppearance.Material.Widget.Button.Colored匹配的资源

你如何在生产模式下运行 react-native 应用程序?

更改整个 React Native App 的语言

Soundcloud API /stream 端点给出 401 错误

React-native 解码 base64 编码字符串

在 React Native 中使用多个上下文提供程序的更好方法

SyntaxError: const 声明中缺少初始化程序

如何使用功能组件向 ref 公开功能?

如何删除不需要的expo 模块

如何将 Tensorflow 与 react-native 一起使用?

WebStorm + ReactNative?

react-native:webview 高度

运行 expo start 时如何禁用在浏览器中打开 DevTools?

如何允许 react-native 启用对 JSX(扩展)文件的支持