Forget Code launches a powerful code generator for building API's

Appium - Create AppiumDriver with desiredcapabilities in Appium

public static AppiumDriver<AndroidElement>  getDriver(){
        if(driver == null)
            try {
            } catch (Exception e) {
                // TODO Auto-generated catch block
        return driver;

    public static void setUp() throws Exception {
            try {
                File classpathRoot = new File(System.getProperty("user.dir"));
                File appDir = new File("<Path of APK>"); //D:/app/build/outputs/apk/
                File app = new File(appDir, "app-debug.apk");
                capabilities = new DesiredCapabilities();
                capabilities.setCapability("deviceName", "Emulator-5554");
                capabilities.setCapability("platformVersion", "5.1.1");
                capabilities.setCapability("noReset", true); //Set to true if .apk need not be Installed for every test run
                capabilities.setCapability("fullReset", false); // Set to true if .apk needs to be installed on every test run
                capabilities.setCapability("app", app.getAbsolutePath());
                capabilities.setCapability("appPackage", "com.flipkart.mobility");
                capabilities.setCapability("elementScrollBehavior", true);
                driver = new AndroidDriver<>(new URL(""), capabilities);
                driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

            } catch (UnreachableBrowserException e) {