前言:使用React Native开发最好保持较为稳定的VPN环境,搭配Expo托管,配合Mac开发环境食用更佳,不然,可能就会像如下情况

1. 由于墙的原因,可以尝试手动安装app

由于国内网络环境问题,按钮expo工具包异常,可能会出现下面所示的错误:

ExpoKit builds constantly failing due to "getaddrinfo ENOTFOUND d1wp6m56sqw74a.cloudfront.net"

我们可以尝试下载对应的apk,放置目录:G:\AndroidSDK\platform-tools,手动安装

1
adb install app_name.apk

2. 模拟器需要调用硬件加速,而电脑设置关闭了

模拟器需要调用硬件加速,而你的电脑默认关闭了硬件加速,则出现以下错误:

emulator: ERROR: x86 emulation currently requires hardware acceleration!Please ensure Intel HAXM is properly installed and usable.CPU acceleration status: HAX kernel module is not installed!

需要在安卓SDK找到intelhaxm-android.exe安装,还可能需要在Boise里面开启VT设置(Virtualization Technology)

3. gradle工具包版本太低

java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

错误原因:gradle版本太低,修改gradle-wrapper.properties文件

1
2
3
4
5
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

4.模拟器无响应或者相应时间过长

Couldn't start project on Android: Error running adb: It took too long to start the Android emulator: Pixel_3a. You can try starting the emulator manually from the terminal

打开模拟器时间过长,可以尝试手动打开

到安卓SDK的emulator目录下使用emulator -avd Pixel_3a打开对应名称的模拟器

使用emulator -list-avds查看所有模拟器列表

最后,放弃安卓studio模拟器吧,用夜神都比较香。