Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
你是如何解释“你是如何理解的?”;java.lang.NoSuchMethodError:无直接方法“;?_Java_Android - Fatal编程技术网

你是如何解释“你是如何理解的?”;java.lang.NoSuchMethodError:无直接方法“;?

你是如何解释“你是如何理解的?”;java.lang.NoSuchMethodError:无直接方法“;?,java,android,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); GoogleAccountC

我们决定,也许是天真的,我们应该将我们的许多库从两年前的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();
List scopes=Lists.newArrayList(sendtogleutils.FUSION\u TABLES\u SCOPE);
GoogleAccountCredential credential=SendToLogLeutils.getGoogleAccountCredential(
上下文、account.name、作用域);
如果(凭证==null){
返回false;
}
Fusiontables Fusiontables=新Fusiontables.Builder(
AndroidHttp.newCompatibleTransport(),new GsonFactory(),credential.build();
我们得到了这个惊人的错误报告:

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)
由以下原因引起的致命异常:java.lang.NoSuchMethodError:无直接方法(Lcom/google/api/client/http/HttpTransport;Lcom/google/api/client/http/HttpRequestInitializer;Ljava/lang/String;Ljava/lang/String;Lcom/google/api/client/json/JSONObject Parser;Lcom/google/api/client/googleapis/services/GoogleClientRequestInitializer;Ljava/lang/String;Z)V类Lcom/google/api/client/googleapis/services/json/AbstractGoogleJsonClient;或者它的超类(声明'com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient'出现在/data/app/dkr.ajijic.apps.tm-1/base.apk中)

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

这只是意味着AbstractGoogleJsonClient的构造函数和特定的参数列表不可用

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


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

发生此问题的原因是Proguard通过Proguard应用此类名和方法名更改,这就是发生NoSuchMethod异常的原因

要解决此错误,请在Proguard规则中添加以下行

-保持类com.google.*{*;}


希望这能解决您的问题。

当源代码目标版本高于设备上使用的操作系统版本时,Android上就有了这一功能。
因此可以访问与操作系统捆绑在一起的库中不存在的方法,因此
NoSuchMethodError

感谢您的回复!我们从不显式地扩展或引用
AbstractGoogleJsonClient
。Fusiontables Builder确实如此,这让我意识到我需要更彻底地更新所有相关的库。我发现我没有更新到:google-api-services-fusionables-v2-rev4-1.20.0.jar。通过更新,我们解决了这个问题。非常感谢你帮助我们理直气壮地思考