使用React本机设置Android模拟器时出现问题 [英] Issue in setting up the Android emulator with React native

查看:94
本文介绍了使用React本机设置Android模拟器时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对React native还是陌生的,并试图通过Visual Studio设置Android环境.所有安装都相当成功,但是,当我尝试在执行 npx react-native run-android 命令的android模拟器上运行示例应用程序时,它显示以下错误-

I am fairly new to React native and trying to set up Android environment with Visual studio. All the installation has been fairly successful, however, when I try to run the sample app on the android emulator executing the npx react-native run-android command it shows below error -

'C:\Users\Home' is not recognized as an internal or external command,
operable program or batch file.
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..

Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
        at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
        at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
        at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:109)

但是,当我在Visual Studio中执行 adb设备时,它会显示已连接的仿真器列表-

However, when i execute adb devices on visual studio, it shows the list of emulator connected -

List of devices attached
emulator-5554   device

可能是什么原因?这是因为我的用户名是家用PC吗?(这是因为它们之间有一个空格),并且它无法获得正确的路径吗?

What could be the possible reason? Is this because my users name is Home PC? (Is this because there is a space in between) and it is not able to get the correct path?

推荐答案

这是因为您的 java 版本已更新为最新版本,并且已安装的版本不支持gradle.您可以做的就是同时更新gradle

This is because your java version is updated to the latest version and gradle is not supported with the installed version. what you can do is update the gradle as well

  1. 因此转到 android 文件夹
  2. 中的 gradle/wrapper 文件夹
  3. 编辑 gradle-wrapper.properties 文件并替换 distributionUrl 具有以下值 https \://services.gradle.org/distributions/gradle-6.3-all.zip

  1. So go to gradle/wrapper folder inside the android folder
  2. Edit gradle-wrapper.properties file and replace distributionUrl with following value https\://services.gradle.org/distributions/gradle-6.3-all.zip

distributionUrl = https \://services.gradle.org/distributions/gradle-6.3-all.zip

这篇关于使用React本机设置Android模拟器时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆