1.问题描述:
下载了一个rn的项目,运行react-native run-android出现了如下错误:
错误: 找不到或无法加载主类 org.gradle.wrapper.GradleWrapperMain
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

2.问题原因:
缺少gradle--->wrapper这个文件夹
3.解决方案:
在查找了相关资料后,定位到了Stack Overflow上的一个解决方案,要有正确的文件才对,我直接从之前的项目中复制了一个gradle进去就可以了。正确的文件如图:

本文解决了在运行React Native项目时遇到的“找不到或无法加载主类org.gradle.wrapper.GradleWrapperMain”错误。问题源于缺少gradle-wrapper文件夹,通过从其他项目复制正确的gradle文件夹并重新运行react-nativerun-android命令,成功解决了问题。
1171

被折叠的 条评论
为什么被折叠?



