java-client icon indicating copy to clipboard operation
java-client copied to clipboard

java-client Start error

Open peibochao123456 opened this issue 6 months ago • 3 comments

my environment: jdk17.0.12 appium:2.18.0

my pom.xml: <groupId>io.appium</groupId> <artifactId>java-client</artifactId> 9.1.0 my code:

UiAutomator2Options options = new UiAutomator2Options(); options.setPlatformName("Android"); options.setPlatformVersion("9"); options.setDeviceName("emulator-5554"); options.setAppPackage("com.android.chrome"); options.setAppActivity("com.google.android.apps.chrome.Main"); options.setAutomationName("UiAutomator2"); options.setNoReset(true); options.setChromedriverExecutable("D:\chromedriver-win64\chromedriver.exe");

    AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723"), options);
    WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20));

error:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Host info: host: 'DESKTOP-PFQTL78', ip: '10.189.102.41' at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:563) at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:268) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:174) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:90) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:102) at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:109) at test.AppiumTest.main(AppiumTest.java:36) Caused by: org.openqa.selenium.WebDriverException: java.lang.NoSuchMethodException: org.openqa.selenium.remote.ProtocolHandshake.createSession(org.openqa.selenium.remote.http.HttpHandler,java.util.function.Supplier,long) Build info: version: '4.32.0', revision: 'd17c8aa950' System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.12' Driver info: driver.version: AndroidDriver at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:137) at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:102) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:176) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:237) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545) ... 6 more Caused by: java.lang.NoSuchMethodException: org.openqa.selenium.remote.ProtocolHandshake.createSession(org.openqa.selenium.remote.http.HttpHandler,java.util.function.Supplier,long) at java.base/java.lang.Class.getDeclaredMethod(Class.java:2675) at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:128) ... 10 more

peibochao123456 avatar May 21 '25 07:05 peibochao123456

@peibochao123456 please check the compatibility matrix

valfirst avatar May 21 '25 12:05 valfirst

Same problem to me (appium 2.18.0)

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.28.0</version>
        </dependency>

        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>9.4.0</version>
        </dependency>

SylvainAssemat avatar May 25 '25 11:05 SylvainAssemat

@SylvainAssemat @peibochao123456

Pinning the Selenium dependency will resolve the issue. I was able to reproduce the issue faced and pinned the Selenium dependencies as follows, fixed it:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>appium-tutorial</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
    <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>9.1.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-remote-driver</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-support</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>4.18.1</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-remote-driver</artifactId>
        <version>4.18.1</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>4.18.1</version>
    </dependency>
    </dependencies>
</project>

pujagani avatar Jun 26 '25 06:06 pujagani