你怎么解释"java.lang.NoSuchMethodError:没有直接的方法"?

Bin*_*ong 8 java android

我们或许天真地决定,我们应该将我们的许多库从两年前的1.12.0-betas更新到漂亮的新版本1.20.0.例如:我们将google-http-client-1.12.0-beta.jar更新为google-http-client-android-1.20.0.jar.

当我们执行此代码时:

  List<String> scopes = Lists.newArrayList(SendToGoogleUtils.FUSION_TABLES_SCOPE);
  GoogleAccountCredential credential = SendToGoogleUtils.getGoogleAccountCredential(
      context, account.name, scopes );
  if (credential == null) {
    return false;
  }
  Fusiontables fusiontables = new Fusiontables.Builder(
      AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential).build();
Run Code Online (Sandbox Code Playgroud)

我们得到这个惊人的错误报告:

FATAL EXCEPTION Caused by: java.lang.NoSuchMethodError: No direct method <init>(Lcom/google/api/client/http/HttpTransport;Lcom/google/api/client/http/HttpRequestInitializer;Ljava/lang/String;Ljava/lang/String;Lcom/google/api/client/json/JsonObjectParser;Lcom/google/api/client/googleapis/services/GoogleClientRequestInitializer;Ljava/lang/String;Z)V in class Lcom/google/api/client/googleapis/services/json/AbstractGoogleJsonClient; or its super classes (declaration of 'com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient' appears in /data/app/dkr.ajijic.apps.tm-1/base.apk)
Run Code Online (Sandbox Code Playgroud)

有人知道怎么解读吗?我们当然不会!

kri*_*son 5

这仅意味着带有特定参数列表的AbstractGoogleJsonClient的构造函数不可用。

检查您super()对的子类的调用,AbstractGoogleJsonClient并确保不需要更新参数列表以匹配更新的库。

如果您的源代码中没有,那么Google API客户端库可能存在库版本依赖性问题。