我无法使用代码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.
但是如果我以根`sudo react-native run-andoid'的身份运行它,它将运行。
如何使项目在没有root用户的情况下运行?
答案 0 :(得分:0)
通过阅读《 Medium》的post,我发现当您在安装本机和实现的工具时遇到权限问题时,您必须显式地授予每个文件夹权限,以便您无需sudo即可运行该应用程序。否则,sudo安装的文件只能以sudo身份运行。
使用以下命令为该特定文件夹的当前用户授予访问权限
sudo chown -R $(whoami) ~/Documents/Myapplicationfolder