appium/java-client

bug: IllegalAccessError when starting AndroidDriver in Appium 9.1.0

MasterfieldProject opened this issue · 4 comments

Do I have the most recent component updates?

  • I use the most recent available driver/plugin and server versions

Is the component officially supported by the Appium team?

  • I have verified the component repository is present under the Appium organization in GitHub

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Using libs:
io.appium:java-client:9.1.0
org.seleniumhq.selenium:selenium-java:4.17.0

When start the android driver it throws IllegalAccessError.

Stacktrace:
`java.lang.IllegalAccessError: class io.appium.java_client.remote.AppiumNewSessionCommandPayload tried to access method 'java.util.stream.Collector com.google.common.collect.ImmutableMap.toImmutableMap(java.util.function.Function, java.util.function.Function)' (io.appium.java_client.remote.AppiumNewSessionCommandPayload and com.google.common.collect.ImmutableMap are in unnamed module of loader 'app')

	at io.appium.java_client.remote.AppiumNewSessionCommandPayload.makeW3CSafe(AppiumNewSessionCommandPayload.java:40)
	at io.appium.java_client.remote.AppiumNewSessionCommandPayload.(AppiumNewSessionCommandPayload.java:54)
	at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:268)
	at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:162)
	at io.appium.java_client.AppiumDriver.(AppiumDriver.java:90)
	at io.appium.java_client.AppiumDriver.(AppiumDriver.java:102)
	at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:109)`

Expected Behavior

It should start the driver successfully.

Minimal Reproducible Example

UiAutomator2Options o = new UiAutomator2Options()
                .setPlatformName("Android")
                .setPlatformVersion("13")
                .setDeviceName("device")
                .setAutomationName("UiAutomator2");
driver = new AndroidDriver(new URL("http://localhost:4723"), o);

Environment

  • Operating system: Windows 10.0.19044 Build 19044
  • Appium server version (output of appium --version): 2.5.1
  • Appium driver(s) and their version(s): UIAutomator2 2.45.1
  • Node.js version (output of node --version): v20.11.0
  • npm version (output of npm --version): 10.2.4
  • Last component(s) version which did not exhibit the problem: 8.6.0
  • Platform and version under test: Android 13, API 33
  • Real device or emulator/simulator: emulator
  • JVM: OpenJDK 17
  • Android Studio: 2023.1.1
  • Gradle: 8.2

Link to Appium Logs

No response

Further Information

No response

You probably have some conflicting version of Google Guava lib in your dependency tree

My project dependencies shows it is com.google.guava.guava:33.0.0.-jre lib. And that is the only one Guava lib in the dep. tree. Is this the compatible version?

I found that however it is com.google.guava.guava:33.0.0-jre (which is compatible) set in the gradle build file, but at runtime the incompatible com.google.guava.guava:33.0.0-android version is set under the gradle cache.

Here is the resolution. Force Gradle to use "-jre" version of Guava instead of "-android".
dependencies.constraints { add("androidTestImplementation", "com.google.guava:guava") { attributes { attribute(TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, objects.named(TargetJvmEnvironment.STANDARD_JVM)) } } }

Reference:
google/guava#6904
google/guava#6801