通过 AppiumDriverLocalSerivce 无法启动 appium service 问题
Posted kingdow
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过 AppiumDriverLocalSerivce 无法启动 appium service 问题相关的知识,希望对你有一定的参考价值。
问题背景描述
通过官方提供的 AppiumDriverLocalService 方法,代码启动 appium server
1 import io.appium.java_client.service.local.AppiumDriverLocalService; 2 import io.appium.java_client.service.local.AppiumServiceBuilder; 3 import io.appium.java_client.service.local.flags.GeneralServerFlag; 4 5 6 /** 7 * @author KingDow 8 * @date 2018/5/18 17:31 9 */ 10 public class AppiumDriverTest { 11 12 public static void main(String[] args) { 13 14 AppiumServiceBuilder builder = new AppiumServiceBuilder() 15 .withArgument(GeneralServerFlag.SESSION_OVERRIDE) 16 .withIPAddress("127.0.0.1") 17 .usingAnyFreePort(); 18 AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder); 19 service.start(); 20 } 21 }
得到以下的报错信息
Exception in thread "main" io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: [C:\Users\KingDow\AppData\Roaming\npm\node_modules\appium\build\lib\main.js, --port, 8000, --address, 127.0.0.1, --session-override] at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:149) at com.ziroom.vayne.appium.server.AppiumDriverTest.main(AppiumDriverTest.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: java.lang.NoSuchMethodError: com.google.common.util.concurrent.SimpleTimeLimiter.create(Ljava/util/concurrent/ExecutorService;)Lcom/google/common/util/concurrent/SimpleTimeLimiter; at org.openqa.selenium.net.UrlChecker.<init>(UrlChecker.java:62) at io.appium.java_client.service.local.AppiumDriverLocalService.ping(AppiumDriverLocalService.java:113) at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:136) ... 6 more Process finished with exit code 1
问题分析定位
引用的第三方依赖包版本冲突,经查找定位为 com.google.guava 版本太低导致,原版本20.0 中没有 SimpleTimeLimiter create() 方法。
问题解决方法
更新guava最新版本后,查看源码create() 方法存在
<!-- https://mvnrepository.com/artifact/com.google.guava/guava --> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>25.1-jre</version> </dependency>
以上是关于通过 AppiumDriverLocalSerivce 无法启动 appium service 问题的主要内容,如果未能解决你的问题,请参考以下文章
java是通过值传递,也就是通过拷贝传递——通过方法操作不同类型的变量加深理解