new AndroidDriver报错java.lang.NoSuchMethodError: com.google.common.base.Throwables.throwIfUnchecked

来源:互联网 发布:软件测试性能测试 编辑:程序博客网 时间:2024/05/18 01:45

在appium初始开发中,发现driver = new AndroidDriver(new URL(appiumServerUrl), capabilities);
语句报错,appium对应的driver session已经正常创建,app应用已经启动,但出现此报错无法继续操作。
java.lang.NoSuchMethodError: com.google.common.base.Throwables.throwIfUnchecked(Ljava/lang/Throwable;)V

java.lang.NoSuchMethodError: com.google.common.base.Throwables.throwIfUnchecked(Ljava/lang/Throwable;)V    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:176)    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)

对应maven 依赖如下:

<parent>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-parent</artifactId>        <!-- <version>2.0.0.M2</version> -->        <version>1.4.2.RELEASE</version>        <relativePath/> <!-- lookup parent from repository -->    </parent>    <properties>        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>        <java.version>1.8</java.version>    </properties>    <dependencies>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-web</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-test</artifactId>            <scope>test</scope>        </dependency>        <dependency>            <groupId>io.appium</groupId>            <artifactId>java-client</artifactId>            <!-- <version>5.0.0-BETA9</version> -->            <version>4.1.2</version>            <exclusions>                <exclusion>                    <groupId>org.springframework</groupId>                    <artifactId>spring-core</artifactId>                </exclusion>                <!-- <exclusion>                    <groupId>org.seleniumhq.selenium</groupId>                    <artifactId>selenium-remote-driver</artifactId>                </exclusion> -->            </exclusions>        </dependency>    </dependencies>

应该是jar依赖的问题,可能发送冲突,或者引入版本不对。查看

com.google.common.base.Throwables.throwIfUnchecked

经过错误位置检查发现此类和方法在
guava-19.0.jar依赖中,后面经过源码查看,确实该com.google.common.base下的类Throwables无此方法,应该是appium的一个bug。后面经过修改maven配置更新此jar包依赖到guava-22.0.jar后能正常创建AndroidDriver没有报错。
修改如下:

<dependency>            <groupId>io.appium</groupId>            <artifactId>java-client</artifactId>            <!-- <version>5.0.0-BETA9</version> -->            <version>4.1.2</version>            <exclusions>                <exclusion>                    <groupId>org.springframework</groupId>                    <artifactId>spring-core</artifactId>                </exclusion>                <!-- <exclusion>                    <groupId>org.seleniumhq.selenium</groupId>                    <artifactId>selenium-remote-driver</artifactId>                </exclusion> -->                <exclusion>                    <groupId>com.google.guava</groupId>                    <artifactId>guava</artifactId>                </exclusion>            </exclusions>        </dependency>        <dependency>            <groupId>com.google.guava</groupId>            <artifactId>guava</artifactId>            <version>22.0</version>        </dependency>
阅读全文
3 0
原创粉丝点击