I'm trying to set a local VM before creating an AWS EC5 machine for my CI to build and test my RN 0.68.2 application (expo ejected):
What's working:
- Build release APK (MacOS + Android Studio)
- Run tests (MacOS + Android Studio)
- Build release APK (VM Ubuntu 22.04 + commandlinetools)
What's not working:
- Run tests (VM Ubuntu 22.04 + commandlinetools)
It seems the script fails at installing the app in the emulator in the VM (See detox logs under)
I tried to use --force-adb-install but it did not fix the issue.
What could prevent shell pm install from installing the app in the emulator?
I can provide some adb logcat logs if needed.
Thanks for your help.
Important parts of Detox logs:
DEBUG: [EXEC_CMD, #16] "/home/ME/android/platform-tools/adb" -s emulator-11072 shell "rm -fr /data/local/tmp/detox"
TRACE: [EXEC_SUCCESS, #16]
DEBUG: [EXEC_CMD, #17] "/home/ME/android/platform-tools/adb" -s emulator-11072 shell "mkdir -p /data/local/tmp/detox"
TRACE: [EXEC_SUCCESS, #17]
DEBUG: [EXEC_CMD, #18] "/home/ME/android/platform-tools/adb" -s emulator-11072 push "/home/ME/repo/myapp/android/app/build/outputs/apk/release/app-release.apk" "/data/local/tmp/detox/Application.apk"
TRACE: [EXEC_SUCCESS, #18] /home/ME/repo/myapp/android/app/build/outputs/apk/release/app-release.apk: 1 file pushed, 0 skipped. 14.6 MB/s (42158675 bytes in 2.763s)
DEBUG: [SPAWN_CMD, #19, cpid=39601] /home/ME/android/platform-tools/adb -s emulator-11072 shell pm install -r -g -t /data/local/tmp/detox/Application.apk
DEBUG: [SPAWN_END, #19, cpid=39601] /home/ME/android/platform-tools/adb -s emulator-11072 shell pm install -r -g -t /data/local/tmp/detox/Application.apk terminated with SIGTERM
TRACE: [SPAWN_TRY_FAIL, #19]
DEBUG: [SPAWN_CMD, #19, cpid=39614] (Retry #1) /home/ME/android/platform-tools/adb -s emulator-11072 shell pm install -r -g -t /data/local/tmp/detox/Application.apk
DEBUG: [SPAWN_END, #19, cpid=39614] /home/ME/android/platform-tools/adb -s emulator-11072 shell pm install -r -g -t /data/local/tmp/detox/Application.apk terminated with SIGTERM
TRACE: [SPAWN_TRY_FAIL, #19]
DEBUG: [SPAWN_CMD, #19, cpid=39623] (Retry #2) /home/ME/android/platform-tools/adb -s emulator-11072 shell pm install -r -g -t /data/local/tmp/detox/Application.apk
DEBUG: [SPAWN_END, #19, cpid=39623] /home/ME/android/platform-tools/adb -s emulator-11072 shell pm install -r -g -t /data/local/tmp/detox/Application.apk terminated with SIGTERM
TRACE: [SPAWN_TRY_FAIL, #19]
DEBUG: [SPAWN_CMD, #19, cpid=39658] (Retry #3) /home/ME/android/platform-tools/adb -s emulator-11072 shell pm install -r -g -t /data/local/tmp/detox/Application.apk
DEBUG: [SPAWN_END, #19, cpid=39658] /home/ME/android/platform-tools/adb -s emulator-11072 shell pm install -r -g -t /data/local/tmp/detox/Application.apk terminated with SIGTERM
ERROR: ChildProcessError: `/home/ME/android/platform-tools/adb -s emulator-11072 shell pm install -r -g -t /data/local/tmp/detox/Application.apk` failed with code null
at ChildProcess.<anonymous> (/home/ME/repo/myapp/node_modules/child-process-promise/lib/index.js:132:23)
at ChildProcess.emit (events.js:400:28)
at maybeClose (internal/child_process.js:1088:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)
Edit 1
Some specs :
- Ubuntu Live Server 22.04 x64 (So WITHOUT GUI)
- Node 14.19.3 + Yarn
- Emulator Package : 'system-images;android-28;default;x86_64'
- Emulator version : 31.2.10.0
- Platform tools version : Android Debug Bridge version 1.0.41 Version 33.0.2-8557947
- Emulator device : pixel_4_xl
- Detox 19.7.1 + jest 26.6.3
Edit 2
I tried using another package (API29) for Pixel 4 XL as it runs on Android Q (API29), and tried to use API28 package with a pixel, nothing changed.
Edit 3
WEll, I ended up on this issue. As the only AOSP package available through sdkmanager is the API 30, I gave it a try. And it failed... BUT, this issue also mentions that something is going wrong when the emulator is not launched prior to launching the tests. So as I saw the emulator having a hard time launching, I ctl+c the process and run it again... AND IT WORKED.
Conclusion
So, while waiting for the Detox team to fix these issues, this is what I ended up with :
- Use AOSP package
- Don't use
--cleanupas it rises an error at the end even if the test passes (this issue - it happened to me locally) - Launch the emulator before running the detox test command.