错误 命令失败:gradlew.bat app:installDebug

error Command failed: gradlew.bat app:installDebug

当我 运行 "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!

OSWindows10 节点:14.2.0 Java: java 版本 "1.8.0_251" Java(TM) SE 运行环境(build 1.8.0_251-b08) Java HotSpot(TM) 64 位服务器 VM(内部版本 25.251-b08,混合模式) Gradle版本:5.1.1

JAVA_HOME、ANDROID_HOME 以及添加到环境的路径

我没有足够的代表发表评论,但是....

今天我运行遇到了这个问题。我的情况是该项目在 mac 上运行良好。但是,我需要在 windows 系统上获取它 运行。在我的 android\app\build.gradle 文件中,我设置了一个 getPassword 方法,使我可以轻松地签署我的 apk。在 getPassword 方法中我有这个调用:

commandLine 'security', '-q', 'find-generic-password', '-a', currentUser, '-s', keyChain, '-w'

我注释掉了所有对 getPassword 方法的引用,它开始正常工作。

问题的根源在于 mac 使用的 "security" 命令行工具在 windows 上不可用。因为我现在也需要使用 windows 框,所以我在外部凭证文件中配置了密码。

我遇到了同样的问题,但是第一个答案太简单了。我不知道如何添加getPassword方法以及在哪里添加。

然而,第一个答案启发了我。 “我的情况是该项目在 mac 上运行良好。但是,我需要在 windows 系统上获取它 运行。 ’

我们应该在 Windows 上将 CLI 命令右移 10. 键入 'cmd' 以通过右键单击使用命令行工具,选择管理员模式。 并再次尝试 'yarn react-native run-android' 或 'npx react-native run-android'。

yarn 会自动下载需要的 gradle 的正确视野。如果您看到这些变化,让我们一起摇滚吧。