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.

Concurrent Android emulators

See original GitHub issue

The problem

I am in most cases unable to run multiple Android emulators concurrently because Appium is unable to find one of the emulators. It looks like a bug to me now but I will explain more and let you decide.

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: 5.1.1, 7.1.1
  • Real device or emulator/simulator: emulator
  • Appium CLI or Appium.app|exe: CLI

Details

There is one case where concurrent emulators actually work, and one where it does not. I will share logs from the case where it does not work.

I run two Appium server instances with the following parameters:

appium --default-capabilities default-capabilities-02.json --port 4725 --bootstrap-port 4726 --chromedriver-port 9515
appium --default-capabilities default-capabilities-03.json --port 4727 --bootstrap-port 4728 --chromedriver-port 9517

default-capabilities-02.json:

{
    "avdArgs": "-port 5556",
    "udid": "emulator-5556"
}

default-capabilities-03.json:

{
    "avdArgs": "-port 5558",
    "udid": "emulator-5558"
}

Run the script below in this order without any emulators running:

python test_android_appium.py chrome 7.1 4725
python test_android_appium.py browser 5.1 4727

Note: Make sure to create AVDs with the names “Nexus_5_5.1” and “Nexus_5_7.1”.

In this case, the first emulator will boot up and run the tests successfully. The second emulator is stuck with a black screen, unable to boot.

I make a note of a couple weird lines in one of the logs:

[debug] [ADB] Telnet command got response: Nexus_5_7.1
[debug] [ADB] Emulator Nexus_5_5.1 not running

There is however a way to make this work by running both commands immediately:

python test_android_appium.py chrome 7.1 4725 &
python test_android_appium.py browser 5.1 4727 &

Both emulators boot up and run the tests. From this point, I can run new tests successfully on both emulators. I suspect that this may not always work.

Link to Appium logs

02: https://gist.github.com/SteffenL/9719119c7d15ddc267cafb49797b2f7c 03: https://gist.github.com/SteffenL/8112fad8ad38ee45a849193a2b90fd86

Code To Reproduce Issue [ Good To Have ]

test_android_appium.py:

import sys
from selenium import webdriver

def main():
    browser = sys.argv[1]
    version = sys.argv[2]
    webdriver_port = sys.argv[3]

    cap = {"browserName": browser, "platformName": "Android", "deviceName": "Android Emulator", "platformVersion": version, "avd": "Nexus_5_{0}".format(version)}
    driver = webdriver.Remote("http://localhost:{0}/wd/hub".format(webdriver_port), cap)
    driver.get("http://www.seleniumhq.org/")
    driver.quit()

if __name__ == "__main__":
    main()

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
imurchiecommented, Jan 6, 2017

I’m seeing the same behavior. Digging a little deeper.

1reaction
imurchiecommented, Jan 6, 2017

Interesting. Looking into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The best Android emulators for PC and Mac of 2022
Android Studio blows all of the competitors out of the water here. It uses an Android Virtual Device (AVD) function that lets developers...
Read more >
10 Best Android Emulators For PCs In 2023
Leapdroid - Fast Android O emulation for Windows that is free to use. SmartGaga - Lightweight Android emulator for low spec PCs. GameLoop...
Read more >
Genymotion – Android Emulator for app testing Cross-platform ...
Emulate 3000+ virtual Android device configurations (Android versions, screen size, hardware capacities, etc.) Simulate every imaginable scenarios thanks to our ...
Read more >
Emulator release notes
If the emulator cannot start a concurrent -read-only instance of an AVD, the emulator now attempts to relaunch the -read-only AVD 3 more...
Read more >
Possible to safely run multiple Android emulators on the ...
Running multiple emulator instances from the Android documentation states that you can run multiple instances concurrently.
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