Skip to content

Indexing : You are currently running with version 2.6.0 of google-api-client... #28187

@risenhoover

Description

@risenhoover

Attempts to use latest version of Indexing client result in error at startup.

// https://mvnrepository.com/artifact/com.google.apis/google-api-services-indexing
libraryDependencies += "com.google.apis" % "google-api-services-indexing" % "v3-rev85-1.18.0-rc"

public static void deindex(String url) {

try {
  Indexing indexing =
      new Indexing.Builder(
              com.google.api.client.googleapis.javanet.GoogleNetHttpTransport
                  .newTrustedTransport(),
              com.google.api.client.json.gson.GsonFactory.getDefaultInstance(),
              null)
          .build();

  UrlNotification notification = new UrlNotification().setUrl(url).setType("URL_REMOVED");

  indexing.urlNotifications().publish(notification).execute();
} catch (Exception e) {
  logger.error(e.getMessage(), e);
}

}

@test
public void testDeindex() {
String url = "https://xxx.io/fr/sosh/us/plfm";
GoogleSearchUtil.deindex(url);
}

java.lang.ExceptionInInitializerError
at com.google.api.services.indexing.v3.Indexing$Builder.build(Indexing.java:417)
at util.GoogleSearchUtil.deindex(GoogleSearchUtil.java:21)
at xxx.util.GoogleSearchUtilTest.testDeindex(GoogleSearchUtilTest.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:231)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: java.lang.IllegalStateException: You are currently running with version 2.6.0 of google-api-client. You need at least version 1.15 of google-api-client to run version 1.18.0-rc of the Indexing API library.
at com.google.common.base.Preconditions.checkState(Preconditions.java:545)
at com.google.api.client.util.Preconditions.checkState(Preconditions.java:113)
at com.google.api.services.indexing.v3.Indexing.(Indexing.java:48)

This seems due to the following code at the top of the Indexing file:

// Note: Leave this static initializer at the top of the file.
static {
com.google.api.client.util.Preconditions.checkState(
com.google.api.client.googleapis.GoogleUtils.MAJOR_VERSION == 1 &&
com.google.api.client.googleapis.GoogleUtils.MINOR_VERSION >= 15,
"You are currently running with version %s of google-api-client. " +
"You need at least version 1.15 of google-api-client to run version " +
"1.18.0-rc of the Indexing API library.", com.google.api.client.googleapis.GoogleUtils.VERSION);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions