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

Hi,

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("http://0.0.0.0:4723/wd/hub"),cap);
// interact with the App - err - stops
Thread.sleep(7000);
driver.quit(); // end the session
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

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.


A
Ashish Thakur Replied on 12/07/2020

Which version of appium are you using?