一身转战三千里,一剑曾当百万师。这篇文章主要讲述通过 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 12public static void main(String[] args) { 13 14AppiumServiceBuilder builder = new AppiumServiceBuilder() 15.withArgument(GeneralServerFlag.SESSION_OVERRIDE) 16.withIPAddress("127.0.0.1") 17.usingAnyFreePort(); 18AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder); 19service.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 moreProcess finished with exit code 1
问题分析定位【通过 AppiumDriverLocalSerivce 无法启动 appium service 问题】引用的第三方依赖包版本冲突,经查找定位为 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>
推荐阅读
- Android动画原理-基础篇(认识View)
- Android+Struts2实现简单的前后台交互--Android网络编程
- Android 动态注册JNI函数
- [yum]Another app is currently holding the yum lock
- Android APP开发内容图片不显示
- Android SQLite数据库升级,怎么做(事物更改)
- 配置文件——App.config文件读取和修改
- Android自定义Dialog多选对话框(Dialog+Listview+CheckBox)
- 不安分的android开发者(小程序初尝试,前后台都自己做)