首页 > 解决方案 > 在 reactNative 中运行模拟器和 gradle 的问题

问题描述

我在模拟器中运行应用程序时遇到问题并给出以下错误:(我在 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

标签: androidreact-native

解决方案


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


推荐阅读