今天跑项目时发现 react-native run-android 跑不起来了。具体报错如下

$ react-native run-android 

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 977 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: spawn ./gradlew EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)

我也是第一次出现这种情况呀,我先是看了一下 android 下面的 ./gradlew 脚本是不是不见了,因为他提示说 ./gradlew 执行失败。可是我 ls 查看了一下这个文件是存在的。但是当我直接执行 ./gradlew 时却执行不了。我本来还以为是我刚升级 android studio 的问题。我以为现在 gradle 需要全局安装了…

结果我一番搜索之后恍然大悟,给个可执行权限试试?于是就可以了。

$ sudo chmod -R +x ./gradlew

啊这,有时候把就不应该把事情想复杂…