【问题标题】:Issue in setting up the Android emulator with React native使用 React native 设置 Android 模拟器的问题
【发布时间】:2020-06-30 08:32:53
【问题描述】:

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

'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 devices 时,它会显示已连接的模拟器列表 -

List of devices attached
emulator-5554   device

可能的原因是什么?这是因为我的用户名是 Home PC 吗? (是不是因为中间有空格)无法获取到正确的路径?

【问题讨论】:

    标签: react-native android-emulator react-native-android


    【解决方案1】:

    这是因为您的java 版本已更新到最新版本,安装的版本不支持 gradle。你可以做的就是更新gradle

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

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

    【讨论】:

    • 谢谢,这个解决方案对我有用。 (我有 jdk 版本 14.0.1,我有 Gradle 6.0.1)
    • 酷!这拯救了我的一天。 :-)
    • 感谢@Amila 的提示。为我工作!
    • 谢谢,我花了 2 天时间解决这个问题,终于节省了我的时间
    【解决方案2】:

    我也遇到了同样的问题。问题出在 JDK 上。从 JDK 14 我降级到 JDK 11(LTS) 版本。它奏效了。 希望对您有所帮助。

    【讨论】:

      【解决方案3】:

      安装Java 8版本,可用Java 8 download

      Gradle 跟不上 Java 最新版本,所以回滚 到以前的版本

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-06-30
        • 2021-05-25
        • 2019-09-07
        • 1970-01-01
        • 1970-01-01
        • 2017-11-13
        • 2017-12-25
        • 2019-05-07
        相关资源
        最近更新 更多