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

问题描述 投票:0回答:3

我在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设置善意建议...等待回应...

java appium appium-ios appium-android appium-desktop
3个回答
0
投票

您可能在类路径中有Guava的冲突版本(即您尝试调用的方法的签名不同)。我之前遇到过NoSuchMethodError,它实际上来自于罐子的冲突版本。看看这个answer。另外看看这个issue


0
投票

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获取所需的版本。


0
投票

尝试使用platformVersion而不是PlatformVersion和deviceName而不是DeviceName。

cap.setCapability("deviceName", "Redmi Note 5");
cap.setCapability("platformVersion", prop.getProperty("platformVersion"));
//or you can use
//cap.setCapability("platformVersion", "8.1.0"); //your android os version directly

如果您使用maven项目添加selenium-java,则不需要使用guava依赖项

© www.soinside.com 2019 - 2024. All rights reserved.