首页 > 解决方案 > DetoxRuntimeError:无法在设备上运行应用程序 -Android

问题描述

在 Pixel_3_API_29 Android 10.0 x86 上运行

我用其他 react-native 代码测试了这个模拟器,发现 Detox 工作正常。

我不确定我的依赖是否会导致问题?

$ detox test -c android.emu.debug                        detox[8179] INFO:  [test.js] configuration="android.emu.debug" reportSpecs=true readOnlyEmu=false useCustomLogger=true DETOX_START_TIMESTAMP=1586124976279 node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:ios:).)*$' --maxWorkers 1 "e2e"

detox[8187] ERROR: [DetoxExportWrapper.js/DETOX_INIT_ERROR] 
 DetoxRuntimeError: Failed to run application on the device

HINT: Most likely, your main activity has crashed prematurely

Native stacktrace dump: 
    at EmulatorDriver._getInstrumentationCrashError (/media/kok/Data/react-native/StellarUI/node_modules/detox/src/devices/drivers/AndroidDriver.js:175:12)
    at EmulatorDriver.instrumentationCloseListener (/media/kok/Data/react-native/StellarUI/node_modules/detox/src/devices/drivers/AndroidDriver.js:142:67)
    at EmulatorDriver._terminateInstrumentation (/media/kok/Data/react-native/StellarUI/node_modules/detox/src/devices/drivers/AndroidDriver.js:166:12)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at ChildProcess.<anonymous> (/media/kok/Data/react-native/StellarUI/node_modules/detox/src/devices/drivers/AndroidDriver.js:260:7) {
  name: 'DetoxRuntimeError'
}
detox[8187] WARN:  [Client.js/PENDING_REQUESTS] App has not responded to the network requests below:
  (id = -1000) isReady: {}

Unresponded network requests might result in timeout errors in Detox tests.
...

其他配置

"jest": {
    "preset": "react-native"
  },
  "detox": {
    "configurations": {
      "android.emu.debug": {
        "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
        "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
        "type": "android.emulator",
        "name": "Pixel_3_API_29"
      },
      "android.emu.release": {
        "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
        "build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
        "type": "android.emulator",
        "name": "Pixel_3_API_29"
      }
    },
    "test-runner": "jest"
  },

地位:

react-native 启动正常

react-native run-android ok

排毒构建确定

排毒测试调试失败!

标签: react-nativejestjsreact-native-androiddetox

解决方案


我遇到了同样的错误,这是因为我使用的 detox 版本还不支持带有 react-native 0.62 的 Android。您需要将 detox 升级到 16.2.0。

见:https ://github.com/wix/Detox/releases/tag/16.2.0


推荐阅读