Error while running code on eclipse regarding mobileapp capabilities

Can anyone please suggest which jar file is suitable to get rid of this error .

Iam getting error at - import io.appium.java_client.remote.MobileCapabilityType;

Below is my code

import java.net.MalformedURLException;

import java.net.URL;

import org.openqa.selenium.WebElement;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.remote.MobileCapabilityType;

public class program1 {

public static void main(String[] args) throws MalformedURLException, InterruptedException {

    DesiredCapabilities dc = new DesiredCapabilities();

    dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium");

    dc.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");

    dc.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");

    dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, "13");

    dc.setCapability("appPackage", "com.oneplus.calculator");
    dc.setCapability("appActivity", "com.android.calculator2.Calculator");

    URL url = new URL("http://127.0.0.1:4723/wd/hub");

    AndroidDriver driver = new AndroidDriver(url, dc);

    // Remember to handle InterruptedException properly
    Thread.sleep(5000);
}

}

Below is my error in eclipse

Exception in thread “main” java.lang.Error: Unresolved compilation problems:
MobileCapabilityType cannot be resolved to a variable
MobileCapabilityType cannot be resolved to a variable
MobileCapabilityType cannot be resolved to a variable
MobileCapabilityType cannot be resolved to a variable

at program1.main(program1.java:16)

Hi @Aleksei came back with one more issue can you please help me in this

Hi @Aleksei got rid of this issue by downloading jar files from

Thanks

This is old version. DesiredCapabilities removed in latest. No we need use UiAutomator2Options or XCUITestOptions

code looks like:

optionsXCUITest
                    .setDeviceName("your_device")
                    .setPlatformName(MobilePlatform.IOS)
                    .setPlatformVersion("your_platform_version")
                    .setShouldTerminateApp(true)
                    .setForceAppLaunch(false)
                    .setWdaLocalPort(5555) // example use any yours if needed
1 Like