在ReactNative中运行模拟器和Gradle时出现问题

时间:2019-09-11 17:46:43

标签: android react-native

我无法在模拟器中运行应用程序 并给出以下错误: (我已经在Genymotion和Nox模拟器上进行了测试)

none
C:\Users\Sajjad Alavi\Desktop\n\test1>npm run android

> @ android C:\Users\Sajjad Alavi\Desktop\n\test1
> react-native run-android

info JS server already running.
info Building and installing the app on the device (cd android && gradlew.bat ap
p:installDebug)...

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Sajjad Alavi\Desktop\n\test1\android\app\build.gradle' line
: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : U
nsupported major.minor version 52.0

* 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

Deprecated Gradle features were used in this build, making it incompatible with
Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:com
mand_line_warnings

BUILD FAILED in 6s
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.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ android: `react-native run-android`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ android script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Sajjad Alavi\AppData\Roaming\npm-cache\_logs\2019-09-11T16
_13_49_689Z-debug.log

2 个答案:

答案 0 :(得分:0)

似乎您使用的JDK版本错误。检查您的JAVA_HOME以使用JDK 1.8

答案 1 :(得分:0)

您应该去 user >> program_data >> gradle 删除缓存 然后,在android studio中运行程序