google-ads-java icon indicating copy to clipboard operation
google-ads-java copied to clipboard

class com.google.ads.googleads.v16.services.stub.GoogleAdsServiceStubSettings overrides final method getEndpoint.()Ljava/lang/String;

Open hyuxi opened this issue 1 year ago • 3 comments

Describe the bug: GoogleAdsClient googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().setLoginCustomerId(3220006497L).build(); Steps to Reproduce: When I upgraded from ads-api 29.0.0 to 30.0.0 V15, the request reported an error Code error fragment: GoogleAdsClient googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().setLoginCustomerId(3220006497L).build(); Expected behavior:

Client library version and API version: Client library version: 30.0.0 Google Ads API version: V16 JDK version: 1.8

Request/Response Logs: Exception in thread "main" java.lang.VerifyError: class com.google.ads.googleads.v16.services.stub.GoogleAdsServiceStubSettings overrides final method getEndpoint.()Ljava/lang/String; at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at com.google.ads.googleads.lib.GoogleAdsHeaderProvider.getHeaders(GoogleAdsHeaderProvider.java:80) at com.google.ads.googleads.lib.AutoValue_GoogleAdsHeaderProvider.getHeaders(AutoValue_GoogleAdsHeaderProvider.java:27) at com.google.ads.googleads.lib.GoogleAdsClient$Builder.getHeaders(GoogleAdsClient.java:566) at com.google.ads.googleads.lib.GoogleAdsClient$Builder.build(GoogleAdsClient.java:638) at com.dayu.data.job.google.TestGetCampaignsJob.main(TestGetCampaignsJob.java:35)

Anything else we should know about your project / environment:

hyuxi avatar Mar 20 '24 04:03 hyuxi

Hi,

This looks like an issue with a dependency conflict caused by the dependencies declared in your project. Could you share the list of dependencies you've specified?

  • If using Maven: mvn dependency:tree
  • If using Gradle: ./gradlew dependencies

Also, if you have any dependencies on the library for the sunset AdWords API such as com.google.api-ads:ads-lib, please remove them. I've noticed that several other users who encountered dependency issues had forgotten to remove this dependency.

Thanks, Josh, Google Ads API Team

jradcliff avatar Mar 20 '24 14:03 jradcliff

We are also facing the same issue when we are migrating from 28.0.0 version to 30.0.0 with jdk 11. I have attached the gradle tree below. v16GradleTree.txt

One thing which we noticed was that by default our google-ads version is picking up 2.37.0 version of com.google.api.gax but the fix for the error coming up is specified in 2.43.0. When we tried migrating com.google.api.gax to 2.43.0 we encountered another error that is: java.lang.AbstractMethodError: Receiver class com.google.api.gax.grpc.GrpcCallContext does not define or inherit an implementation of the resolved method 'abstract com.google.api.gax.rpc.ApiCallContext withEndpointContext(com.google.api.gax.rpc.EndpointContext)' of interface com.google.api.gax.rpc.ApiCallContext.

at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:233)
at com.google.ads.googleads.v16.services.stub.GrpcGoogleAdsServiceStub.create(GrpcGoogleAdsServiceStub.java:96)
at com.google.ads.googleads.v16.services.stub.GoogleAdsServiceStubSettings.createStub(GoogleAdsServiceStubSettings.java:188)
at com.google.ads.googleads.v16.services.GoogleAdsServiceClient.<init>(GoogleAdsServiceClient.java:207)
at com.google.ads.googleads.v16.services.GoogleAdsServiceClient.create(GoogleAdsServiceClient.java:189)
at com.google.ads.googleads.lib.catalog.GeneratedCatalog$V16Client.createGoogleAdsServiceClient(GeneratedCatalog.java:1469)

Please help us with a resolution for the same

sdlmalavika avatar Mar 21 '24 11:03 sdlmalavika

Hi @sdlmalavika ,

Just upgrading gax dependencies without also upgrading grpc, protobuf, guava, etc. is likely to cause problems. This library's com.google.api-ads:google-ads:30.0.0 expects the following dependencies:

Dependencies Version
io.grpc:* 1.61.1
com.google.api:gax* 2.43.0
com.google.protobuf:protobuf* 3.25.2
com.google.guava:guava* 32.1.3
com.google.auth:google-auth-library* 1.23.0

One way to avoid having to figure out all the dependency versions and keep them in sync is to use the Cloud Client Libraries BOM (com.google.cloud:libraries-bom) described here:

https://cloud.google.com/java/docs/bom

Version 30.0.0 of the google-ads library is compatible with version 26.33.0 of libraries-bom. Could you try that approach and let me know if that resolves this issue for you?

Thanks, Josh, Google Ads API Team

jradcliff avatar Mar 21 '24 14:03 jradcliff

HI @jradcliff Below are my mvn dependency:tree. Which error will still be reported. maven dependencies.txt Please help me with a resolution Thanks

hyuxi avatar Mar 22 '24 10:03 hyuxi

Hi @hyuxi ,

I see from the output that you have the following conflicting direct dependencies:

  • com.google.api:gax:jar:2.32.0
  • com.google.api:gax-grpc:jar:2.43.0

Could you try updating your com.google.api:gax dependency from 2.32.0 to 2.43.0?

Thanks, Josh

jradcliff avatar Mar 22 '24 13:03 jradcliff

Hi @jradcliff
Thanks for your answer, I have solved this problem.Thanks

hyuxi avatar Mar 25 '24 02:03 hyuxi

Thanks for the update, @hyuxi.

@sdlmalavika , I'm closing this issue since I haven't seen any follow-up comments from you in several days, but feel free to reopen it if you're still encountering issues.

Cheers, Josh

jradcliff avatar Mar 25 '24 13:03 jradcliff