java.lang.NoSuchMethodError : com. google.common.collect.ImmutableSortedSet.toImmutableSortedSet(Ljava/util/Comparator;)Ljava/util/stream/Collector;

标签 java appium appium-ios appium-android appium-desktop

我收到 Appium 设置无法启动应用程序的错误。我正在使用下面的配置设置:

java-client = 3.1.0
selenium-java = 3.11.0
appium-version = 1.7.0

还添加了以下依赖项,但仍然面临同样的问题:

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.5</version>
</dependency> 

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>18.0</version>
</dependency>

我设置的以下功能:

File app = new File(prop.getProperty("apkFilePath"));
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("DeviceName", "Redmi Note 5");
cap.setCapability("PlatformVersion", prop.getProperty("platformVersion"));
cap.setCapability("platformName", "Android");
cap.setCapability("app", app.getAbsolutePath());
try{
    driver=new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"),cap);
}catch(Exception e){
    e.printStackTrace();
}


Error: java.lang.NoSuchMethodError: 
    com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(Ljava/util/Comparator;)Ljava/util/stream/Collector;
    at org.openqa.selenium.remote.NewSessionPayload.lambda$validate$4(NewSessionPayload.java:199)
    at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:372)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:373)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
    at org.openqa.selenium.remote.NewSessionPayload.validate(NewSessionPayload.java:215)
    at org.openqa.selenium.remote.NewSessionPayload.(NewSessionPayload.java:163)
    at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:114)

请看看如何解决这个问题。我最近两天正在尝试,但仍然面临同样的问题。 还有其他方法可以解决此 appium 设置问题,请建议... 等待友好回复...

最佳答案

selenium-java-3.11 需要 Guava 23.6-jre as per the pom.xml :

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>23.6-jre</version>
  <classifier></classifier>
</dependency>

您已降级到更旧的 Guava 版本,从 pom.xml 中删除您自己的版本,并让 selenium 选择所需的版本。

关于java.lang.NoSuchMethodError : com. google.common.collect.ImmutableSortedSet.toImmutableSortedSet(Ljava/util/Comparator;)Ljava/util/stream/Collector;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52363536/

相关文章:

ios - 如何获取 Appium 中元素的子元素列表?

gitlab - 使用 appium 为移动自动化设置 gitlab cicd?

javascript - 如何使用 iOS appium 的 UI Automation JavaScript Reference 获取 native 应用程序字体类型或样式

java - Java bean 和实现 Comparable 等接口(interface)的约定是什么?

java - 为什么我在这里收到 NotSerializedException?

java - Java 中的持续时间差异

java - Appium Java Sauce Labs 云测试 : Ran Desired Capabilities got Sauce Labs Authentication Error

java - 如何从项目中删除jar文件?

java - 无法找到 Android 日期选择器元素

ios - 如何让 Appium 以真实的 iOS 设备与模拟器设备为目标