Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: IllegalAccessError when starting AndroidDriver in Appium 9.1.0 #2124

Closed
3 tasks done
MasterfieldProject opened this issue Feb 22, 2024 · 4 comments
Closed
3 tasks done
Labels

Comments

@MasterfieldProject
Copy link

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

@MasterfieldProject MasterfieldProject changed the title bug: IllegalAccessError in Android Studio when starting AndroidDriver bug: IllegalAccessError when starting AndroidDriver in appium 9.1.0 Feb 22, 2024
@MasterfieldProject MasterfieldProject changed the title bug: IllegalAccessError when starting AndroidDriver in appium 9.1.0 bug: IllegalAccessError when starting AndroidDriver in Appium 9.1.0 Feb 22, 2024
@mykola-mokhnach mykola-mokhnach transferred this issue from appium/appium Feb 22, 2024
@mykola-mokhnach
Copy link
Contributor

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

@MasterfieldProject
Copy link
Author

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?

@MasterfieldProject
Copy link
Author

MasterfieldProject commented Feb 23, 2024

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.

@MasterfieldProject
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants