1) install Appium + Node
2) Install Android Studio as well and create a virtual device on that i have created with name : Nexus_5X_API_25_1
3) Download LinkedIn.apk file from below link.
4) Now For automating any android app we need to know the package and activity names.
So Lets find them.
For this set your PATH variable to point to below directories.
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/build-tools/26.0.2
above version can be anything in my case it is 26.0.2
after setting the above path variables run the below command.
aapt dump badging “<Path to LinkedIn.apk>”
Output of above command will contain below 2 values.
package: name='com.linkedin.android'
launchable-activity: name=‘com.linkedin.android.authenticator.LaunchActivity'
5) So we got the package name and activity name too. Now we should frame the desired capabilities section. Like this(In my machine)
{
"platformName": "Android",
"deviceName": "Android Emulator",
"app": "/Users/sriramkukkadapu/Downloads/LinkedIn.apk",
"automationName": "Appium",
"platformVersion": "7.1.1",
"appPackage": "com.linkedin.android",
"appActivity": "com.linkedin.android.authenticator.LaunchActivity",
"avd": "Nexus_5X_API_25_1”
}
6) Now start appium with above capabilities and you can see it will open the app :)
Note: IP and the port number values would be the one which we give, when we start the node/appium server
Code:
public class AndroidDriverEx {
public static void main(String args[]) throws IOException, InterruptedException
{
WebDriver driver=null;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", "/Users/sriramkukkadapu/Downloads/LinkedIn.apk");
capabilities.setCapability("automationName","Appium");
capabilities.setCapability("platformVersion","7.1.1");
capabilities.setCapability("appPackage","com.linkedin.android");
capabilities.setCapability("appActivity","com.linkedin.android.authenticator.LaunchActivity");
capabilities.setCapability("avd","Nexus_5X_API_25_1");
driver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Thread.sleep(3000);
driver.quit();
}
Now we are good to go and automate all the actions which you wanted to automate.