Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android Setup] - Detox can't seem to connect to the test app(s) #4195

Open
mackwill opened this issue Sep 19, 2023 · 6 comments
Open

[Android Setup] - Detox can't seem to connect to the test app(s) #4195

mackwill opened this issue Sep 19, 2023 · 6 comments

Comments

@mackwill
Copy link

Description

So im setting up detox in our project - and everything seems to be running smoothly on iOS

On android however, i cannot seem to get the tests to run at all. I can build just fine, but when i try to run a test, this is the error that i get. (Currently on APK level 33)

14:53:29.199 detox[20768] i ws-server Detox server listening on localhost:63329...
14:53:29.204 detox[20768] B lifecycle jest --config jest.config.js myTest

Determining test suites to run...
14:53:30.451 detox[20771] i child-process:EXEC_CMD "/Users/myUser/Library/Android/sdk/platform-tools/adb"  devices
14:53:40.173 detox[20771] i child-process:EXEC_SUCCESS List of devices attached
emulator-5554   device


14:53:40.176 detox[20771] i device:DEVICE_LOOKUP Found a matching & free device emulator-5554
14:53:40.179 detox[20771] i child-process:EXEC_CMD "/Users/myUser/Library/Android/sdk/platform-tools/adb" -s emulator-5554 shell "getprop ro.build.version.sdk"
14:54:04.279 detox[20771] i child-process:EXEC_CMD "/Users/myUser/Library/Android/sdk/platform-tools/adb" -s emulator-5554 shell "dumpsys power | grep \"^[ ]*m[UW].*=\""
14:54:31.454 detox[20771] i child-process:EXEC_CMD "/Users/myUser/Library/Android/sdk/build-tools/33.0.0/aapt" dump badging "/Users/myUser/Documents/MyApp/native/android/app/build/outputs/apk/dev/debug/app-dev-debug.apk"
14:54:31.795 detox[20771] i lifecycle workOrderCreate.test.ts is assigned to AttachedDevice:emulator-5554
14:54:33.051 detox[20771] i child-process:EXEC_CMD "/Users/myUser/Library/Android/sdk/platform-tools/adb" -s emulator-5554 shell "am force-stop com.commas.my.app.dev"
14:54:55.540 detox[20771] i child-process:EXEC_CMD "/Users/myUser/Library/Android/sdk/platform-tools/adb" -s emulator-5554 shell "date +\"%m-%d %T.000\""
14:55:19.642 detox[20771] i child-process:EXEC_CMD "/Users/myUser/Library/Android/sdk/platform-tools/adb" -s emulator-5554 reverse tcp:63329 tcp:63329
14:55:37.701 detox[20771] i child-process:EXEC_CMD "/Users/myUser/Library/Android/sdk/platform-tools/adb" -s emulator-5554 shell "pm list instrumentation"
14:56:04.845 detox[20771] i ws-client:ERROR Detox can't seem to connect to the test app(s)!

HINT: 

Have you forgotten to call 'device.launchApp()' in the beginning of your test?
Refer to our troubleshooting guide, for full details: https://wix.github.io/Detox/docs/troubleshooting/running-tests#tests-execution-hangs

---
The following package could not be delivered:

{
  type: 'invoke',
  params: [Object],
  messageId: 1
}


 FAIL  __test__/testFolder/myTest.test.ts (154.855 s)
  ● Create Work Order flow › Should create a simple work order

    No instrumentation runner found on device emulator-5554 for package com.commas.my.app.dev


    > 15 |     await device.launchApp();
         |                  ^
      16 |   });
      17 |
      18 |   afterAll(async () => {

      at Object.launchApp (__test__/myTests/myTest.test.ts:15:18)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)


14:56:04.984 detox[20768] E lifecycle Command failed with exit code = 1:
jest --config jest.config.js myTest
14:56:04.985 detox[20768] i ws-server Detox server has been closed gracefully
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.

There have been a number of issues opened about this and i have tried all of the available solutions but have had no success in getting things to run.
I know that there isn't officially support for RN 0.72 yet, but i want to know if anyone has had any success on this version of RN, or if it really is just the version that im on that's causing the issue.

note my current folder structure is

root/
-- node_modules
--src
--ios
--android
--e2e (detox is in here)

Here's the android section of the .detoxrc file

  apps: {
    "android.dev.debug": {
      type: "android.apk",
      binaryPath: `../android/app/build/outputs/apk/dev/debug/app-dev-debug.apk`,
      testBinaryPath: `../android/app/build/outputs/apk/androidTest/dev/debug/app-dev-debug-androidTest.apk`,
      build: `cd ../android && ./gradlew app:assembleDevDebug app:assembleDevDebugAndroidTest -DtestBuildType=debug && cd ..`,
    },
  },

in my build.gradle file

allprojects {
    repositories {
        google()
        maven {
            url("$rootDir/../e2e/node_modules/detox/Detox-android")
        }
        maven { url "https://jitpack.io" }
    }
}

And at the beginning of my tests, i have the call for deviceLaunch in my beforeAll - i know that the tests themselves are fine because i run them on iOS no problem.
I can't really pinpoint where the issue is now, but as i said i've tried other solutions like adding testBinaryPath and tweaking my android/app/build.gradle file to the following like some other suggestions here

    androidTestImplementation('com.wix:detox:+') {
        exclude module: "protobuf-lite"
    }
    implementation 'androidx.appcompat:appcompat:1.1.0'

Any help here would be appreciated.

Your environment

Detox version: 20.12.1
React Native version: 0.72.4
Node version:
Device model:
OS:
Test-runner (select one): jest

@drajnamichal
Copy link

drajnamichal commented Sep 21, 2023

The same for me...can't figure out where the problem is

@mackwill
Copy link
Author

yeah - seems to be a common issue but would love some support for this. Its definitely impeding rollout of testing if we can't get it up and running on android

@drajnamichal
Copy link

any news @mackwill ?

@only1chi
Copy link

only1chi commented Dec 9, 2023

I have the same problem. Does anyone have any solution? This happens on the Github runner, but I can run detox locally on my M1 machine.

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

@stale stale bot added the 🏚 stale label Mar 17, 2024
@cleberada
Copy link

Same issue, any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants