0
尝试使用Google Ads API Java Client Library访问AdWords API的(代码片段从项目的README拍摄):谷歌广告API的Java客户端库:java.lang.NoSuchMethodError:com.google.common.base.Preconditions.checkNotNull
val credential = new OfflineCredentials.Builder()
.forApi(OfflineCredentials.Api.ADWORDS)
.withClientSecrets(clientId, clientSecret)
.withRefreshToken(refreshToken)
.build()
.generateCredential()
这将失败并显示错误:
[info] Exception encountered when attempting to run a suite with class name: AdwordsClientSpec *** ABORTED ***
[info] java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkNotNull(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;
[info] at com.google.api.ads.common.lib.auth.OfflineCredentials$Api.<init>(OfflineCredentials.java:89)
[info] at com.google.api.ads.common.lib.auth.OfflineCredentials$Api.<clinit>(OfflineCredentials.java:81)
[info] at AdwordsClient$.generateAdwordsCredential(AdwordsClient.scala:24)
[info] at AdwordsClientSpec$$anonfun$1.apply$mcV$sp(AdwordsClientSpec.scala:23)
[info] at AdwordsClientSpec$$anonfun$1.apply(AdwordsClientSpec.scala:18)
[info] at AdwordsClientSpec$$anonfun$1.apply(AdwordsClientSpec.scala:18)
[info] at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
[info] at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
[info] at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info] at org.scalatest.Transformer.apply(Transformer.scala:22)
看起来像某些依赖项未正确解析。我用的是最新的自述与SBT提到的两个文物的版本:
"com.google.api-ads" % "ads-lib" % "3.5.0",
"com.google.api-ads" % "adwords-axis" % "3.5.0"
这看起来像一个番石榴版本冲突 - 你在你的项目中的任何番石榴依赖关系(直接还是间接)? (除了Google API库中使用的)。如果您不确定 - 请编辑帖子以包含您的SBT依赖关系的_all_。 –
@TzachZohar谢谢你的提示,这是解决这个问题的一个有用的出发点。 –