英文:
Java io.appium clashes with io.grpc
问题
我正在创建一些使用Java 11程序(使用Maven)进行Android测试,并使用gRPC与其他设备进行通信。
Appium依赖项
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.3.0</version>
</dependency>
gRPC依赖项
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.53.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.53.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.53.0</version>
</dependency>
当我运行程序时,我遇到了错误。
警告:[org.testng.ITest]类[com.framework.DynamicTest]上的实现返回null。默认为方法名
java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.toImmutableMap(Ljava/util/function/Function;Ljava/util/function/Function;)Ljava/util/stream/Collector;
at io.appium.java_client.remote.AppiumNewSessionCommandPayload.makeW3CSafe(AppiumNewSessionCommandPayload.java:40)
at io.appium.java_client.remote.AppiumNewSessionCommandPayload.<init>(AppiumNewSessionCommandPayload.java:54)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:229)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:80)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:92)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:117)
错误发生在我执行这一行时。
mobileDriver = new AndroidDriver(new URL(strURL), capabilities);
看起来AndroidDriver未被检测到。但是当我移除gRPC依赖时,它可以工作。
是否有可能解决使用io.appium与io.grpc的问题?
英文:
I'm create some java 11 program (use maven) which using Appium for android testing and gRPC to communicate with other device.
Appium Dependency
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.3.0</version>
</dependency>
gRPC Dependency
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.53.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.53.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.53.0</version>
</dependency>
When I run the program, I got error
Warning: [org.testng.ITest] implementation on class [com.framework.DynamicTest] returned null. Defaulting to method name
java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.toImmutableMap(Ljava/util/function/Function;Ljava/util/function/Function;)Ljava/util/stream/Collector;
at io.appium.java_client.remote.AppiumNewSessionCommandPayload.makeW3CSafe(AppiumNewSessionCommandPayload.java:40)
at io.appium.java_client.remote.AppiumNewSessionCommandPayload.<init>(AppiumNewSessionCommandPayload.java:54)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:229)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:80)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:92)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:117)
The error occurs when I hit this line
mobileDriver = new AndroidDriver(new URL(strURL), capabilities);
It's look like the AndroidDriver not detected. But when I remove gRPC dependency, it's work.
Is there a possible solution to using io.appium together with io.grpc?
答案1
得分: 1
在添加了guava依赖项(不是最新版本)之后,错误得到了解决。
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
感谢@San P提供的建议。
英文:
After add guava dependency (not the latest version), the error is resolved.
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
Thankyou to @San P for giving advice.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论