selenium: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V

Hello,

I have browser Google Chrome 57.0.2987.133 (64-bit), webdriver chrome ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233), Java java version “1.8.0_131” Java™ SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot™ 64-Bit Server VM (build 25.131-b11, mixed mode).

Tried to run Code on Java

        System.setProperty("webdriver.chrome.driver", "C:\\Server\\templates\\selenium\\chromedriver.exe");
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
//this statement will not show any warnings when you launch chrome
        options.addArguments("test-type");
//start a maximized window
        options.addArguments("start-maximized");
//this allows you to use a user profile
        capabilities.setCapability("chrome.binary", "C:\\Server\\templates\\selenium\\chromedriver.exe");
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
        WebDriver driver = new ChromeDriver(capabilities);

and returned error

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:111)
	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:302)
	at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:146)

How to solve this problem?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23

Most upvoted comments

Change version package guava. Upgrade to guava-21.0.jar and this problem resoved.

download updated guava jar https://github.com/google/guava/wiki/Release22

It works for me…

worked for me

Upgraded guava to version 22. It fixed the issue.

@asifraaja Use guava version 22.0

I ran into a similar problem, then I ran “mvn dependency:tree” to see if there was another module (e.g. google-api-client-appengine) having dependency on guava-jdk5. Apparently guava-jdk5 is interfering with guava.jar. Depending which jar was loaded first, you may or may not run into NoSuchMethodError.

In the pom.xml, I added an explicit guava 22.0 as dependency and added an exclusion of guava-jdk5

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>22.0</version>
</dependency>
 <dependency>
     <groupId>com.google.api-client</groupId>
     <artifactId>google-api-client-appengine</artifactId>
     <version>1.23.0</version>
     <exclusions>
        <exclusion>
          <groupId>com.google.guava</groupId>
          <artifactId>guava-jdk5</artifactId>
       </exclusion>
    </exclusions>
 </dependency>

I am also getting the same error as you are getting @ritesh2689 can anybody please help me here. I have also used the guava 23 and guava 22 version.but still getting the same error.

conflict with some jars

To resolve this issue Remove if you have added any jar files under referenced Library as it creates conflicts. Remove the jar it should work fine.