react-native run-android 不起作用:/

Posted

技术标签:

【中文标题】react-native run-android 不起作用:/【英文标题】:react-native run-android does not work :/ 【发布时间】:2021-09-18 23:08:35 【问题描述】: 在 Windows 中运行 react-native run-android 但出现此错误:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.   
  (node:8484) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
Jetifier found 896 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
'gradlew.bat' n'est pas reconnu en tant que commande interne
ou externe, un programme ex�cutable ou un fichier de commandes.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn gradlew.bat ENOENT
    at notFoundError (C:\cygwin64\home\Abderrahmane\app\node_modules\cross-spawn\lib\enoent.js:6:26)      
    at verifyENOENT (C:\cygwin64\home\Abderrahmane\app\node_modules\cross-spawn\lib\enoent.js:40:16)      
    at ChildProcess.cp.emit (C:\cygwin64\home\Abderrahmane\app\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
info Run CLI with --verbose flag for more details.`

我已经安装了 android studio 并创建了一个项目 我还运行了模拟器,我做到了

create-react-native-app project
react-native init project
react-native start
react-native run-android

【问题讨论】:

你试过实现这个reactnative.dev/docs/environment-setup还是这个tutorialspoint.com/react_native/…? 非常感谢:3 我会在答案部分写下来。如果解决方案有帮助,请打勾。 【参考方案1】:

你可以试试这个react native environment setup from react native official documentation或者这个react native environment setup from tutorialspoint一个

【讨论】:

【参考方案2】:

对于 android 试试这个代码:

 # Reset metro bundler cache : 
`npx react-native start --reset-cache`
    
# Remove Android assets cache : 
`cd android && ./gradlew clean`
    
# Relaunch metro server : 
`npx react-native run-android`

要移除“Jetifier”,请使用:

react-native run-android --no-jetifier

【讨论】:

以上是关于react-native run-android 不起作用:/的主要内容,如果未能解决你的问题,请参考以下文章

使用 react-native run-android 运行时出现 React-Native 错误

react-native run-android 失败

运行 react-native run-android 时出错

react-native run-android 失败 MacOS

react-native run-android 不起作用:/

运行 react-native run-android 时出错