当我运行“ react-native run-android”或“ npx react-native run-android”或“ cd andriod ./gradlew clean”这些命令时,错误将显示
PS D:\work\Myproject-app> npx react-native run-android
info Starting JS server...
Starting a Gradle Daemon, 2 incompatible and 2 stopped Daemons could not be reused, use --status for details
> Configure project :app
Reading env from: .env
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
A problem occurred evaluating project ':app'.
> A problem occurred starting process 'command 'security''
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified.
* 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 19s
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.bat app:installDebug. Run CLI with --verbose flag for more details.
我也尝试使用最新版本的Gradle!
OS Windows 10 节点:14.2.0 Java:Java版本“ 1.8.0_251” Java(TM)SE运行时环境(内部版本1.8.0_251-b08) Java HotSpot(TM)64位服务器VM(内部版本25.251-b08,混合模式) Gradle版本:5.1.1
JAVA_HOME,ANDROID_HOME和添加到环境的路径
答案 0 :(得分:2)
我没有足够的代表发表评论,但是....
我今天遇到了这个问题。我的情况是该项目在Mac上运行良好。但是,我需要使其在Windows系统上运行。在我的android \ app \ build.gradle文件中,我设置了一个getPassword方法,该方法使我可以轻松地对我的apk进行签名。在getPassword方法中,我有以下调用:
commandLine 'security', '-q', 'find-generic-password', '-a', currentUser, '-s', keyChain, '-w'
我注释掉了对getPassword方法的所有引用,它开始正常工作。
问题的根源是Mac使用的“安全”命令行工具在Windows上不可用。由于现在还需要使用Windows框,因此我已经在外部凭据文件中配置了密码。
答案 1 :(得分:1)
我遇到了同样的问题,但第一个答案太简单了。我不知道如何添加 getPassword 方法以及在哪里添加。
然而,第一个答案启发了我。 “我的情况是该项目在 Mac 上运行良好。但是,我需要让它在 Windows 系统上运行。 ’
我们应该在 Windows 10 上右移 CLI 命令。键入“cmd”以通过右键单击使用命令行工具,选择管理员模式。 并再次尝试“yarn react-native run-android”或“npx react-native run-android”。
yarn 会自动下载需要的 gradle 的正确视觉。如果您看到这些变化,让我们振作起来。