0

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?

jon_17z
  • 91
  • 7
  • 1
    Couple of things: - can you use the latest gRPC version (1.56.1)? - if it still fails with the grpc latest version, try using the maven enforcer plugin https://maven.apache.org/enforcer/enforcer-rules/requireUpperBoundDeps.html to make sure the build is using the latest required version for Guava. And if the enforced flags an error explicitly depend on that guava version. Hope that works – San P Jul 13 '23 at 20:40
  • Thankyou I already try it but it's still generate same error – jon_17z Jul 14 '23 at 07:59

1 Answers1

1

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.

jon_17z
  • 91
  • 7