I'm trying to run my Espresso tests on CI (Jenkins in this case) server. I do not have access to the GUI over here so the approach I have decided on is using -no-window parameter on Android Emulator. Emulator starts fine however I receive Error: Could not access the Package Manager. Is the system running?
error during installation process. So as I mentioned above, is there any way that I could run Espresso tests on non-gui machine? I know there is Jenkins plugin for Android Emulator but it seems to be outdated, last update is from 2015 I belive.. thanks!

- 472
- 5
- 19
-
This is possible: https://paulemtz.blogspot.de/2013/05/android-testing-in-headless-emulator.html. Emulator must be using software gpu rendering: `-gpu off` – R. Zagórski Jul 11 '17 at 09:50
-
It doesn't work, same Package Manager error appears – henorek Jul 11 '17 at 10:52
2 Answers
I had the same problem with the running espresso tests on the emulator in the docker container. The problem occurred when I tried to run Activity. Instrumental Unit Tests were working.
When I switched from x86_64 image to x86 tests pass. I run emulator using this command: emulator -avd Nexus6P -netdelay none -netspeed full -no-window -no-audio -gpu off

- 156
- 4
According to the internet (e.g. SO) you will get this error message if the emulator is not fully started or the device is locked.
You can try two things:
Send unlock keyevent to device (first check if device is online)
./adb devices
./adb shell input keyevent 82
Wait until device is fully started
./adb shell getprop init.svc.bootanim
// You should get "1" when ready
I currently have the exact same problem and sadly none of the above solutions is working for me. I guess the best way to identify the problem is to run the emulator with GUI to see what it is doing but I don't have access to the server.
Let me know if you can solve your problem.
Edit: Also try to do a sleep for a few minutes (about 10 mins if your server isnt that fast) before calling
./adb install
or ./gradlew connectedAndroidTest
Edit#2:
My emulator is finally working but had to use x86 images. Still no idea why arm is not working..