使用 React Native 应用程序,在 Android 模拟器上运行测试时面对
Detox Runtime Error
。
我已经在我的机器(macbook)上配置了android,并且能够在模拟器上运行该应用程序。执行排毒测试时产生了
DetoxRuntimeError: There was no "adb" executable file in directory
错误。
我有以下设置和配置,但对我不起作用,任何帮助都会得到帮助。
当前的android环境设置
.zshrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
export ANDROID_HOME=/Users/sagar/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=~/Library/Android/sdk
亚行版本
> adb --version
Android Debug Bridge version 1.0.41
Version 34.0.5-10900879
Installed as /usr/local/bin/adb
Running on Darwin 23.5.0 (x86_64)
设备配置为运行
.detoxrc
Android 的 Detox 配置
/** @type {Detox.DetoxConfig} */
module.exports = {
apps: {
"android.debug": {
type: "android.apk",
binaryPath: "android/app/build/outputs/apk/debug/app-debug.apk",
build:
"cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug",
reversePorts: [8081],
},
"android.release": {
type: "android.apk",
binaryPath: "android/app/build/outputs/apk/release/app-release.apk",
build:
"cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release",
},
},
devices: {
attached: {
type: "android.attached",
device: {
adbName: ".*",
},
},
emulator: {
type: "android.emulator",
device: {
avdName: "Pixel 3a API 34",
},
},
},
configurations: {
"android.att.debug": {
device: "attached",
app: "android.debug",
},
"android.att.release": {
device: "attached",
app: "android.release",
},
"android.emu.debug": {
device: "emulator",
app: "android.debug",
},
"android.emu.release": {
device: "emulator",
app: "android.release",
},
},
};
为了解决上述问题,我在 mac 机器上的
zshrc file
中更新了以下配置,并得到了解决。
用
.zshrc
更新 code ~/.zshrc
并执行 source ~/.zshrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
export ANDROID_HOME=/Users/sagar/Library/Android/sdk
export PATH=$PATH:$ANDROID_ROOT/emulator
export PATH=$PATH:$ANDROID_ROOT/tools
export PATH=$PATH:$ANDROID_ROOT/tools/bin
export PATH=$PATH:$ANDROID_ROOT/platform-tools
export PATH=$PATH:~/.android-sdk-macosx/platform-tools/