File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/build/outputs/apk/");
File  = new File(appDir, "-debug.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","");
capabilities.setCapability("-version", "1.0");
capabilities.setCapability("platformName", "");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "Your package name");
capabilities.setCapability("appActivity", "MainActivity");

Explanation:

Line 1: Get the to your Project’s Root Directory
O/P: classPathRoot: /Users/john.doe/AppiumProject/app

Line 2: Append the Path to the Directory of the folder where your “.apk” is placed, with the Project’s Root Directory.
O/P: classPathRoot: /Users/john.doe/AppiumProject/app/build/outputs/apk/

Line 3: Append your “.apk” file name, with the Project’s Root Directory(till your apk folder).
O/P: classPathRoot: /Users/john.doe/AppiumProject/app/build/outputs/apk/apk-debug.apk

Line 4 and onwards: Initiate Desired capabilitieas and them as per your platform and device



Source link https://sqa.stackexchange.com/questions/10018/how-to-set-app-path-for-android-using-appium-on-a-

LEAVE A REPLY

Please enter your comment!
Please enter your name here