I am getting error "The constructor AndroidDriver<MobileElement>(URL, DesiredCapabilities) is undefined". | Appium Forum
Chitresh Kumar Posted on 07/07/2020


I am getting an error saying that ""The constructor AndroidDriver<MobileElement>(URL, DesiredCapabilities) is undefined" when creating an object of AndroidDriver and passing URL and DesiredCapabilities. I have written the code as below:

import java.io.File;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

public class LaunchAmazonApp {

public static void main(String[] args) {

String apkPath = "F:\\Appium\\Extracted apk files\\Amazon_in.amazon.mShop.android.shopping.apk";
File appPath = new File(apkPath);

/* tell appium server - message
- Device id
- Device name
- Android device
- version
- apk path
- activity name and package name

DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.UDID, "2c79bbd7");
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "2c79bbd7");
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.0");
cap.setCapability(MobileCapabilityType.APP, appPath.getAbsolutePath());
// default - app is re installed
cap.setCapability(MobileCapabilityType.NO_RESET, "true");// dont clear the cache
cap.setCapability(MobileCapabilityType.FULL_RESET, "false");// dont uninstall
//cap.setCapability("appPackage", "com.makemytrip");
//cap.setCapability("appActivity", "com.mmt.travel.app.home.ui.SplashActivity");

try {
AndroidDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL(""),cap);
// interact with the App - err - stops
driver.quit(); // end the session
} catch (Exception e) {
// TODO Auto-generated catch block

Could you please help me to solve this error? I have searched a lot but couldn't find anything. I have added a screen shot for jar files added.

Ashish Replied on 12/07/2020

Which version of appium are you using?