Describe the bug
My binaryPath setting for android.emu.debug in .detoxrc.json is:
"binaryPath": "android/app/build/outputs/apk/debug/app-x86_64-debug.apk",
However, running detox test --configuration android.emu.debug gives an error message with a totally different path:
detox[52593] ERROR: Error: 'projects/android/app/build/outputs/androidTest/x86_64/debug/app-x86_64-debug-androidTest.apk' could not be found, did you run './gradlew assembleAndroidTest'?
I can't find any references to this androidTest directory. How do I get Detox to point to an apk that actually exists, in the debug directory?
To Reproduce
My repro is just first-time setup and running detox test. I've successfully run the detox build command for the same config. So, it appears that the build command is not building at the same path that the test command is looking for.
(Skipping logs as they have personal information and do not appear relevant, can sanitize them and paste if need be.)
Environment (please complete the following information):
jest-circusDetox appears to be referencing the binaryPath but attempting to transform it in a way that's broken (at least on my machine).
When I change binaryPath to this:
android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
I get a different error message than above, as if Detox is attempting to use part of my binaryPath but mangling the rest. Note the "androidTest-androidTest" and "androidTest/debug/androidTest/" repetition, which is not present in my binaryPath.
detox[54397] ERROR: Error: 'android/app/build/outputs/apk/androidTest/debug/androidTest/app-debug-androidTest-androidTest.apk' could not be found, did you run './gradlew assembleAndroidTest'?
The build is succeeding and writing to the directory above (apk/androidTest/debug/app-debug-androidTest.apk) but again, test is using a different path than build and can't find the file. I'm using this command to ensure that the same config is definitely used for both:
detox build -c android.emu.debug && detox test -c android.emu.debug
If I use a truly nonexistent path then Detox does not appear to modify it. I'm at a loss to explain why it modifies the path if the apk DOES exist and then does not find it.
"binaryPath": "does/not/exist.apk",
detox[54805] ERROR: Error: app binary not found at 'does/not/exist.apk', did you build it?
Truly does not exist, and is not mangled or modified.
If you have a custom testBinaryPath, then make sure to specify it as well in the config. See Device configuration.
Are you sure there is a problem with automatic test binary path resolution for the majority of Detox users?
This does appear to be a common issue:
https://stackoverflow.com/questions/53984667/detox-app-could-not-be-found-did-you-run-gradlew-assembleandroidtest/63414420#63414420
https://stackoverflow.com/questions/53984667/detox-app-could-not-be-found-did-you-run-gradlew-assembleandroidtest/63414420#63414420
I found that Detox is mutating the path because it tries to transform it in getTestApkPath(). I don't have any custom settings, but setting testBinaryPath does work, thanks for the suggestion.
I would suggest adding a step to the documentation for users to try using testBinaryPath as an override. Intuitively it seems Detox would be asking for a binaryPath to the binary you want Detox to use, but that's not what binaryPath is for - Detox tries to compute the path to its APK using binaryPath as a base. I (and others) would think that binaryPath should be the path to Detox's binary.
Created PR here: https://github.com/wix/Detox/pull/2277
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 reporsitory, read this discussion.
The issue has been closed for inactivity.
This just tripped me up.
It does not correctly automate the paths for the test binary when you have multiple arch apks

Most helpful comment
This just tripped me up.
It does not correctly automate the paths for the test binary when you have multiple arch apks