question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android emulator does not quit automatically

See original GitHub issue

The problem

When running Selenium tests on an Android virtual device, the device does not power off after the test ends, and the emulator does not quit.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.6.3
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: macOS 10.12.2
  • Node.js version (unless using Appium.app|exe): 7.1.0
  • Mobile platform/version under test: Android 5.1.1, 6.0, 7.1.1
  • Real device or emulator/simulator: Emulator
  • Appium CLI or Appium.app|exe: Appium CLI

Details

I have a basic Python script that runs a simple test with Selenium and Appium in a web browser.

The test runs all right but afterwards, the emulator itself never quits. I expected that it would behave like the iOS simulator.

Since the emulator does not quit automatically, I can also not conveniently run tests on another virtual device on the same host machine (attempting to do so can lead Appium to crash).

Link to Appium logs

https://gist.github.com/SteffenL/2f01cad53d43bf5ec34a54e00c386aaf

Code To Reproduce Issue [ Good To Have ]

Sample code: sample-code/examples/python/android_simple.py

A simpler example:

from selenium import webdriver

cap = {"browserName": "Browser", "platformName": "Android", "deviceName": "Android Emulator", "platformVersion": "5.1.1", "automationName": "Appium", "avd": "Nexus_5_5.1.1"}
driver = webdriver.Remote("http://localhost:4723/wd/hub", cap)
driver.get("http://www.seleniumhq.org/")
driver.quit()

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
artgocommented, May 7, 2017

+1 how can we influence to increase the priority of this ticket? 😃

1reaction
tavramovcommented, Oct 23, 2020

In appium@beta UIA2 driver got a feature, which allows to directly control the emulator using its console commands.

@mykola-mokhnach - this UIA2 feature works to close the emulator but i think there is a little bit of a chicken-and-egg problem. The issue is that if you call driver.executeScript(“mobile: execEmuConsoleCommand”, “kill”, “device_udid”) before driver.quit(), driver.quit() will fail because emulator is gone. And you cant execute the kill command after driver.quit() because session will be null. IMO, closing the emulator needs to be made part of the driver.quit() call routine. Agree with @jlipps previous suggestion that maybe the kill command in driver.quit() can be conditional on the avd capability. Does this sound reasonable?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Solved] My android emulator (AVD) shut down automatically
Go to Menu->Tools->Android and uncheck the option Enable ADB Integration Run the application. Now the emulator will be launched, but app will ...
Read more >
Troubleshoot known issues with Android Emulator
To do so, in the emulator window, click on Settings > View Mode and select Window instead of Dock Pinned.
Read more >
How to Power Off / Restart Android Device Emulator in ...
Android AVD Simulator not Working | Fix AVD Simulator in Android Studio | AVD Simulator Black Screen · How to Remove Root (Un...
Read more >
6 Ways To Fix Android Emulator App Keeps Crashing/Stopping
Way 1: Check for Enough Disk Space · Way 2: Unsupported Version Of Mac OS · Way 3: Antivirus Software To Fix Android...
Read more >
What's the proper way to shit down the emulator? : r/androiddev
Sometimes I've seen the qemu process become orphaned - closing Android Studio does not kill the emulator process. In cases like that, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found