我无法使用代码react-native run-android
运行react-native项目。我收到以下错误
info Starting JS server...
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not create service of type AnnotationProcessorDetector using JavaGradleScopeServices.createAnnotationProcessorDetector().
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
error 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/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.
但是如果我以root身份运行它“sudo react-native run-andoid”,它就会运行。
如何让项目在没有root权限的情况下运行?
最佳答案
我通过阅读post发现by Medium 指出,当您在安装 React Native 和相关工具时遇到权限问题时,您必须明确授予每个文件夹权限,以便您可以在无需 sudo 的情况下运行应用程序。否则 sudo 安装的文件只能作为 sudo 运行。
使用以下命令授予当前用户对该特定文件夹的访问权限
sudo chown -R $(whoami) ~/Documents/Myapplicationfolder
关于javascript - 如果我不是 Sudo,React-Native 无法运行项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56162662/