繁体   English   中英

“命令失败:./gradlew installDebug”问题(react-native run-android)

[英]"Command failed: ./gradlew installDebug" Problem (react-native run-android)

我在 macOS 平台上处理 React Native 项目时遇到问题。 我的项目在 IOS 模拟器上正常运行,但在 Android 模拟器上不起作用。

这是错误日志:

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Configure project :app
WARNING: The specified Android SDK Build Tools version (28.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '28.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Task :app:checkDebugClasspath FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find react-native.jar (com.facebook.react:react-native:0.58.4).
  Searched in the following locations:
      file:/Users/asena/Desktop/deneme/Deneme/node_modules/react-native/android/com/facebook/react/react-native/0.58.4/react-native-0.58.4.jar

* 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
1 actionable task: 1 executed
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

Command failed: ./gradlew installDebug

Error: Command failed: ./gradlew installDebug
    at checkExecSyncError (child_process.js:637:11)
    at Object.execFileSync (child_process.js:655:13)
    at runOnAllDevices (/Users/asena/Desktop/deneme/Deneme/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
    at buildAndRun (/Users/asena/Desktop/deneme/Deneme/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
    at isPackagerRunning.then.result (/Users/asena/Desktop/deneme/Deneme/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

我该如何解决这个问题? 你有什么建议?

谢谢,

您可能只是安装了不同版本的 React Native。

快速而肮脏的解决方法是将版本更改为"com.facebook.react:react-native:+"

更好的方法是进入你的 node_modules,找到实际的包版本,并在你的 gradle 脚本中更改版本以匹配。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM