Launching Native App in your Android device using Appium

You already know what are Desired Capabilities and how to launch a web browser from previous article. Now lets launch a native app. You also know how to create an AVD, if not then take a look at this article. Get the device name using the command ‘adb devices‘. Here, we are going to take an example of the Android calculator app.

Things to do:
Launch emulator
Launch Appium server – type ‘appium
Get the device name – type ‘adb devices
Get the package name and activity name of calculator app – refer article
Set the capabilities (package name and activity name) – refer article


Now, create a class in your project, let’s say ‘LaunchNativeApp‘ and paste the below code in that class

private AndroidDriver driver;

public void setUp() throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
//set the platform version
caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, “4.4.2“);
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android“);
caps.setCapability(MobileCapabilityType.DEVICE_NAME, “Android emulator“);
//set the emulator name
caps.setCapability(“avd”, “CharanAvd“);
driver = new AndroidDriver(new URL(“”),
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

public void calculatorAddition() {
WebElement nine = driver.findElement(“9”));;
WebElement plus = driver.findElement(“+”));;
WebElement seven = driver.findElement(“7”));;
WebElement equalTo = driver.findElementByAccessibilityId(“equals”);;

public void tearDown() {

Hope, it worked. Your code launches calculator app and perform an operation. Notice here, I was using ‘AccessibilityId‘ locator for ‘=’ button, instead of ‘name’ or ‘ID’. You can use any locator. Try to locate other buttons as well.

You know, we need to set capabilities to start a session. Here, I’m using an emulator, so the device name was my emulator’s. My platform version was 4.4.2. Since i am using calculator app, it’s package name is ‘‘ and activity name is ‘‘.

Sending a post request to server saying, CharanAvd having version 4.4.2 wants to launch an application having package name as ‘’ and activity name as ‘’. Then UIAutomator/Selendroid/Appium will talk to bootstrap.jar which is running your device to perform an action. Then bootstrap.jar acts a TCP server establish a connection.

Hope this is clear. You can download the code from here.


One thought on “Launching Native App in your Android device using Appium

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s