Run AVD Emulator detached from terminal - android

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

Related

Run Android Emulator with Jenkins Pipeline on Windows

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

Android app is not launching in Emulator

When I am trying to launch an app in the emulator through Eclipse, the app is not launching and I am not getting any error also.
WHen I check in the target section of project properties, I can't see any AVD in the list even though I created a new AVD and it is running.
Your android emulator might fails to connect eclipse DDMS tool and ask for adb to start manually. In that case you can start or stop the adb using the command prompt.So, I recommend running in a single command line:
sudo adb kill-server && sudo adb start-server
If not works please switch To Android Studio .Eclipse is dead .

Android Emulator - Command Line Building

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 &

emulator command doesn't work in crontab (start GUI in contab)

I've wrote a script test.sh for android automation testing, here require start emulator each time
PATH="$PATH:/home/xxx/tool/jdk1.6.0_34/bin:/home/xxx/tool/android-sdk-linux/tools:"
emulator -avd avd22
I put test.sh in crontab, but looks emulator can't come up in crontab, but manually I execute test.sh, all things work fine.
fix it by adding following command before emulator command
export DISPLAY=:0 && emulator -avd avd22

How to attach back the Android emulator to ADB?

After I start the emulator by hitting Debug in Eclipse, after certain time it disconnects from the ADB, but the emulator stays open. It is responsive, I can navigate and start apps.
How can I attach back the emulator to ADB, to be able to debug from Eclipse?
(the current workaround is the terminate the emulator, close Eclipse and restart both of them, which takes 10 minutes as you know the emulator needs time to start up)
EDIT 1
Check out this image:
EDIT 2
After I kill and restart server. One emulator process shows up in Devices tab in Eclipse. But that cannot be expanded, and I don't see sub-processes.
I can't hit debug already, as it says: Debug already running. (How to I stop the debug?)
If I managed to start the debugging of another project, It hangs out in the emulator telling me: Waiting for the debugger to attach. Nothing happens.
As you said, the problem is not Eclipse losing contact with the Emulator, but ADB - the Android Debug Bridge - losing contact with it. As Eclipse uses ADB to communicate with the emulator when ADB is broken Eclipse can do nothing.
To fix this stop the ADB server by running the following command:
adb kill-server
Eclipse will then usually try to restart ADB, or you can restart it yourself by running an ADB command, such as:
adb devices
If you do, you'll see output like this:
* daemon not running. starting it now *
* daemon started successfully *
List of devices attached
emulator-5554 device
You can also do this via the mouse, using the Reset adb option in the Devices view in Eclipse.
It's also worth noting the Console view has two modes, DDMS and Android. You're usually in Console mode but it's DDMS mode which will show ADB status messages. Select modes by clicking the button with the Monitor icon, or using the arrow next to it:
If all else fails, try killing the adb processes from the OS. On Windows XP I use:
TASKKILL /F /IM adb.exe
There is an easier way. From eclipse you can reset the adb from DDMS panel.
Here's a short video on doing that "Reset ADB on DDMS"
Here's a quick screenshot of where you can get the option.
Sometimes a kill-server won't help at my machine (WinXP). For example I can't see the emulator in the DDMS-View any more or I do see it but no processes running on it.
In these cases I close the emulator and eclipse and manually kill the adb.exe-process from the process list.
When I then restart eclipse and the emulator, everything's fine again.
Now I just need a keyboard-shortcut for that :-)
on a mac, i just had to kill adb from activity manager and manually re-open the program again. had eclipse open all through and it worked just fine.
Try with adb kill-server and adb start-server. Even then the same problem occurs kill your running process from ddms prespective. Refer this link(http://www.jiahaoliuliu.com/2011/02/stopping-android-applications-already.html). This solved my issue. Hope for you also.
I am testing an application on an Android 4.0 (API level 14) emulator and once I run the app the emulator starts up and as soon as it loads, Eclipse DDMS disconnects from the emulator.
Here is the workaround that I am using: Open terminal, navigate to platform tools (C:\android-sdk\platform-tools\ or wherever you have your android-sdk installed), and run adb kill-server, and then run, adb start-server. DDMS should now list the emulator - from Java perspective, right click on the app -> Run As -> Android Application.
Hope this helps.
My handy bash script
#!/bin/bash
./path/to/adb kill-server
./path/to/adb start-server
./path/to/adb devices

Categories

Resources