I am using a Android Emulator to run some tests where a need to send some information with adb commands so I created a Pipeline where the first stage is running the emulator with this command in the pipeline
bat 'emulator -avd Pixel_2_Test -no-window -no-audio wait-for-device'
When I use this command the job breaks, I think beacause is a daemon, so I tried to use start in the begin of the command to execut in backgroud, so in the next step I have:
bat 'adb devices'
I have this to see if the emulator is running but never return nothing, only never stop this step. I have to finished the job manually. I don't know if the emulator is really runing on background mode and I dont know why the adb command never stop. Please help me. I dont know how to run this emulator on the pipeline on Windows
Related
Here is how we can run AVD directly from terminal
emulator -list-avds
emulator #Pixel_3a_API_30_x86
But I want it to be detached so that I can close my terminal and have the emulator still running. I tried to run something like this:
emulator -d #Pixel_3a_API_30_x86
But I got an error. Can someone tell how can we do that?
Try the nohup command:
Nohup, short for no hang up is a command in Linux systems that keep processes running even after exiting the shell or terminal.
nohup `emulator #Pixel_3a_API_30_x86 &`
here & puts the application into the background.
Alternatively on Zsh.
emulator #Pixel_4_API_31 &|
https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html
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!
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
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..
I am using Jenkins Pipeline to Checkout,Build and Launch Espresso tests on my emulator before archiving the APK,The problem is that I cannot launch the emulator automatically from Jenkins.However with the same command from Windows command line I am able to run the emulator:
Script
node{
// Previous stages and some magic...
stage('Test') {
bat "D:\\Tools\\Dev\\sdk\\tools\\emulator.exe -avd Nexus_5X_Marshmallow_API_23"
}
}
Screenshots of Jenkins Logs and same command on windows
Does anybody have an idea about what can be done to fix this issue ?
You shuold try running your command with single quotation marks:
bat 'D:\\Tools\\Dev\\sdk\\tools\\emulator.exe -avd Nexus_5X_Marshmallow_API_23'
I am also not shure if you need to escape your path.
I'm trying to start the emulator, on a mac(sierra) jenkins slave like this:
/Users/username/Library/Android/sdk/tools/emulator -avd Nexus_5_API_25 -wipe-data
And the build hangs. It starts the emulator, but it does not proceed with the build.
I guess I need to start it as a background process, which should be something like this:
/Users/username/Library/Android/sdk/tools/emulator -avd Nexus_5_API_25 -wipe-data $
but I get an error:
invalid command-line parameter: $.
What would be the correct way of starting the emulator without blocking the build?
edit: I would like to solve this without installing the android emulator plugin(I have no rights, or permission to install it)
Back again on Stack needing help from fellow Android Developers. In my development environment im using a lot of command line building and management. Currently im running into a issue where the Terminal "Using Mac OSX" when executing the command "emulator -avd nameOfemulator" the Terminal is still live.
Example of Launching Emulator
However even when the emulator is open and live, The Terminal is not let go to be able to execute additional command, I dont want to just open a new tab or window to have to execute my adb command's. Currently i can closes the emulator and kill the live terminal/emulator command by a simple 'ctrl-C' however this defeats the purpose if the emulator is closed.
Does anybody know of anyway of getting the terminal live again, either through a script, string of commands, different type of emulator's, etc.
UPDATE
Now running the following command emulator -avd NexusSeven & This emulator has the HAX Intel Hardware Acceleration enabled. And shortly after the terminal becomes available again, The string "HAX is working and emulator runs in fast virt mode" is inputted into the command input and makes the terminal live again.
Since MacOSX is just a fork of BSD Linux, the emulator can be run in background by appending the ampersand:
emulator -avd NexusSeven &
To ignore all output, the following command will help:
emulator -avd NexusSeven > /dev/null 2>&1 &