Gradle with Selenium

Hi,

I am trying to use Gradle(4.5.1) with Selenium (Java) and Chromedriver ( chrome v 64, chromedriver 2.35). This is how my dependency section looks in build.gradle

dependencies {
compile ‘com.google.api-client:google-api-client:1.23.0’
compile ‘com.google.oauth-client:google-oauth-client-jetty:1.23.0’
compile ‘com.google.apis:google-api-services-sheets:v4-rev506-1.23.0’
compile group: ‘org.seleniumhq.selenium’, name: ‘selenium-java’, version: ‘2.9.0’
compile group: ‘org.seleniumhq.selenium’, name: ‘selenium-chrome-driver’, version: ‘2.9.0’
}

==

I am using ancient selenium libraries (2.9.0). Whenever I try to use selenium libraries 3.0+, I get below exception when I do gradle run:

Exception in thread “main” java.lang.NoSuchMethodError:

com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)
at Quickstart.main(Quickstart.java:130)

My selenium code is really simple two liner:

System.setProperty(“webdriver.chrome.driver”, “C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe”);
WebDriver driver = new ChromeDriver();

==

More details here: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;) with Selenium, gradle and ChromeDriver - Stack Overflow

Please guide, what could be missing, why latest selenium jars are not working. Gradle is using Maven repository,

Thank you!

Anyone? Waiting for a reply.

Mostly these kind of errors indicate a library conflict. Please activate failOnVersionConflict and report whether gradle reports some conflict.