我在MacOS平台上处理React Native Project时有问题。我的项目在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)
如何解决此问题?您的建议是什么?
谢谢,
您可能只安装了反应本机的不同版本。
快速而肮脏的修复是将版本更改为 "com.facebook.react:react-native:+"
。
可能更好的是进入您的node_modules,找到实际的软件包版本,然后更改Gradle脚本中的版本以匹配。