简体   繁体   中英

“main” java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, char, java.lang.Object)'

I am getting this error, even after trying different versions of jars available and unable to find the Preconditions class in my intelliJ workspace.
Not sure why this method is getting called. I'm getting this runtime exception every time i run the code.
I am trying grpc and protobuffers for the first time but I'm not sure what to do about the below error.

 "main" java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkArgument( boolean, java.lang.String, char, java.lang.Object)'

My dependencies look like this:

 <dependencies>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-all</artifactId>
            <version>1.29.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.auto.value</groupId>
            <artifactId>auto-value-annotations</artifactId>
            <version>1.6.2</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>4.2.2</version>
        </dependency>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>20.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.8</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.1.49.Final</version>
        </dependency>
    </dependencies>

And my mvn dependency:tree o/p is below .

[INFO] +- io.grpc:grpc-all:jar:1.29.0:compile
[INFO] |  +- io.grpc:grpc-api:jar:1.29.0:compile (version selected from constraint [1.29.0,1.29.0])
[INFO] |  +- io.grpc:grpc-auth:jar:1.29.0:compile
[INFO] |  |  \- com.google.auth:google-auth-library-credentials:jar:0.20.0:compile
[INFO] |  +- io.grpc:grpc-context:jar:1.29.0:compile
[INFO] |  +- io.grpc:grpc-core:jar:1.29.0:compile (version selected from constraint [1.29.0,1.29.0])
[INFO] |  |  +- com.google.code.gson:gson:jar:2.8.6:compile
[INFO] |  |  +- com.google.android:annotations:jar:4.1.1.4:compile
[INFO] |  |  \- io.perfmark:perfmark-api:jar:0.19.0:compile
[INFO] |  +- io.grpc:grpc-grpclb:jar:1.29.0:compile
[INFO] |  |  +- com.google.protobuf:protobuf-java:jar:3.11.0:compile
[INFO] |  |  \- com.google.protobuf:protobuf-java-util:jar:3.11.0:compile
[INFO] |  +- io.grpc:grpc-netty:jar:1.29.0:compile
[INFO] |  |  +- io.netty:netty-codec-http2:jar:4.1.48.Final:compile (version selected from constraint [4.1.48.Final,4.1.48.Final])
[INFO] |  |  |  +- io.netty:netty-common:jar:4.1.48.Final:compile
[INFO] |  |  |  +- io.netty:netty-buffer:jar:4.1.48.Final:compile
[INFO] |  |  |  +- io.netty:netty-transport:jar:4.1.48.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-resolver:jar:4.1.48.Final:compile
[INFO] |  |  |  +- io.netty:netty-codec:jar:4.1.48.Final:compile
[INFO] |  |  |  +- io.netty:netty-handler:jar:4.1.48.Final:compile
[INFO] |  |  |  \- io.netty:netty-codec-http:jar:4.1.48.Final:compile
[INFO] |  |  \- io.netty:netty-handler-proxy:jar:4.1.48.Final:compile
[INFO] |  |     \- io.netty:netty-codec-socks:jar:4.1.48.Final:compile
[INFO] |  +- io.grpc:grpc-okhttp:jar:1.29.0:compile
[INFO] |  |  +- com.squareup.okio:okio:jar:1.13.0:compile
[INFO] |  |  \- com.squareup.okhttp:okhttp:jar:2.7.4:compile
[INFO] |  +- io.grpc:grpc-protobuf:jar:1.29.0:compile
[INFO] |  |  +- com.google.api.grpc:proto-google-common-protos:jar:1.17.0:compile
[INFO] |  |  \- io.grpc:grpc-protobuf-lite:jar:1.29.0:compile
[INFO] |  +- io.grpc:grpc-services:jar:1.29.0:compile
[INFO] |  +- io.grpc:grpc-stub:jar:1.29.0:compile
[INFO] |  +- io.grpc:grpc-testing:jar:1.29.0:compile
[INFO] |  |  \- io.opencensus:opencensus-api:jar:0.24.0:compile
[INFO] |  \- io.grpc:grpc-xds:jar:1.29.0:compile
[INFO] |     +- io.grpc:grpc-alts:jar:1.29.0:compile
[INFO] |     |  +- org.apache.commons:commons-lang3:jar:3.5:compile
[INFO] |     |  +- org.conscrypt:conscrypt-openjdk-uber:jar:2.2.1:compile
[INFO] |     |  \- com.google.auth:google-auth-library-oauth2-http:jar:0.20.0:compile
[INFO] |     |     +- com.google.http-client:google-http-client:jar:1.34.0:compile
[INFO] |     |     |  +- org.apache.httpcomponents:httpclient:jar:4.5.10:compile
[INFO] |     |     |  |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |     |     |  |  \- commons-codec:commons-codec:jar:1.11:compile
[INFO] |     |     |  \- io.opencensus:opencensus-contrib-http-util:jar:0.24.0:compile
[INFO] |     |     \- com.google.http-client:google-http-client-jackson2:jar:1.34.0:compile
[INFO] |     |        \- com.fasterxml.jackson.core:jackson-core:jar:2.10.1:compile
[INFO] |     +- io.opencensus:opencensus-proto:jar:0.2.0:compile
[INFO] |     \- io.grpc:grpc-netty-shaded:jar:1.29.0:compile (version selected from constraint [1.29.0,1.29.0])
[INFO] +- com.google.auto.value:auto-value-annotations:jar:1.6.2:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- commons-cli:commons-cli:jar:1.4:compile
[INFO] +- com.google.guava:guava:jar:22.0:compile
[INFO] |  +- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] |  +- com.google.errorprone:error_prone_annotations:jar:2.0.18:compile
[INFO] |  +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] |  \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.4.8:compile
[INFO] \- io.netty:netty-all:jar:4.1.49.Final:compile

I have checked the existing posts as well on this issue but none seems to be working for me. I believe there might be some issue with the versions but all the versions seem to be giving this error only.

Problem with a 3rd Party Library:

"main" java.lang.NoSuchMethodError: 
'void com.google.common.base.Preconditions.checkArgument(  
         boolean, java.lang.String, char, java.lang.Object)'

Let's try to update guava

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>21.0</version>
    </dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, java.lang.Object) Maven - NoSuchMethodError: void com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, java.lang.Object) Error :: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V with IE and Selenium through Java java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument Google Cloud KMS java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V Cloud Vision API Exception in thread “main” java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;) NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM