Java – Does Appium need to manually start the Android emulator?

Does Appium need to manually start the Android emulator?… here is a solution to the problem.

Does Appium need to manually start the Android emulator?

I’m new to appium and I’m running the calculator sample test using the following code:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","AndroidTestDevice");
capabilities.setCapability("platformName","Android");    
capabilities.setCapability("appPackage", "com.android.calculator2");       
capabilities.setCapability("appActivity","com.android.calculator2.Calculator");
driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);

Appium is running, as you can see in the following screenshot:

enter image description here

If the emulator doesn’t run, I get an error related to device not found.
My question is:

Do I need to manually start the emulator every time I need to perform a test? Or does Appium launch the Android emulator while performing tests?

enter image description here

Solution

Enable “Boot AVD” in your settings and enter the name of the Android virtual device you created. This will start the emulator when you start testing, if it is not already started.

Update:

You need to set up AVD capabilities. Simply add this line to your code capabilities.setCapability("avd","AndroidTestDevice");

Related Problems and Solutions