1

I'm trying to run the code here. However it is returning a java.lang.NoSuchMethodError: io.grpc.ManagedChannelBuilder.disableServiceConfigLookUp()Lio/grpc/ManagedChannelBuilder; I've determined that the error is caused by the line try (ImageAnnotatorClient vision = ImageAnnotatorClient.create()).

I've looked online but I haven't been able to find any information on this other than it potentially being a versioning issue. However, I'm using dependencies stated on the quickstart guide so I'm not sure how to resolve this.

Naman
  • 27,789
  • 26
  • 218
  • 353

1 Answers1

1

NoSuchMethodError’ is a generic non-Google Java runtime error caused by a maven dependency conflict. This is specifically a Java dependency conflict concerning the ‘io.grpc’ library as noted in the error.

As explained in the Maven documentation, you can use the following command to see what version of “io.grpc” dependency is installed in your local environment that is causing the issue:

mvn dependency:tree -Dverbose -Dincludes=io.grpc 

Once you have identified the conflicting Java dependency after running the previous command, you can then try to resolve the conflict by performing these generic steps:

  1. Try a clean install of maven: mvn clean install and execute the file.
  2. You can update all versions to the latest release: mvn versions:use-latest-releases and execute the file.
  3. Follow the additional recommendations noted in this similar Stack Overflow post which addresses the “NoSuchMethodError” issue.

As a workaround, I tested the Quickstart code in Google Cloud Shell and it runs flawlessly (as Cloud Shell has pre-installed packages which are up to-date and reset upon closing). So for testing purposes you can run the code in the Cloud Shell instead of in your local environment.

Ivana S
  • 123
  • 5