你如何解释“java.lang.NoSuchMethodError:没有直接方法”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32041260/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you interpret "java.lang.NoSuchMethodError: No direct method"?
提问by BinCodinLong
We decided, perhaps naively, that we should update many of our libraries from two-year-old 1.12.0-betas to nice new versions 1.20.0. For example: we updated google-http-client-1.12.0-beta.jar to google-http-client-android-1.20.0.jar.
我们决定,也许是天真,我们应该将许多库从两年前的 1.12.0-beta 更新到不错的新版本 1.20.0。例如:我们将 google-http-client-1.12.0-beta.jar 更新为 google-http-client-android-1.20.0.jar。
When we execute this code:
当我们执行这段代码时:
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();
we get this amazing error report:
我们得到了这个惊人的错误报告:
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)
Does anybody know how to interpret it? We sure don't!
有人知道怎么解释吗?我们肯定不会!
采纳答案by kris larson
It just means that a constructor for AbstractGoogleJsonClient with a particular argument list wasn't available.
这只是意味着具有特定参数列表的 AbstractGoogleJsonClient 的构造函数不可用。
Check your super()
calls for your subclass(es) of AbstractGoogleJsonClient
and make sure you don't need to update the argument list to match your updated libraries.
检查您super()
对 的子类的调用,AbstractGoogleJsonClient
并确保您不需要更新参数列表以匹配更新的库。
If that's not in your source code, then there may be a library version dependency issue with Google API client library.
如果这不在您的源代码中,那么 Google API 客户端库可能存在库版本依赖性问题。
回答by M.Noman
This issue is happened because of Proguard is applied via Proguard this class name and methods name changes that why NoSuchMethod exception is occurring.
发生这个问题是因为 Proguard 是通过 Proguard 应用的,这个类名和方法名改变了为什么会发生 NoSuchMethod 异常。
To resolve this error please add below line into you Proguard rules.
要解决此错误,请将以下行添加到您的 Proguard 规则中。
-keep class com.google.** { *; }
-keep class com.google.** { *; }
Hopefully this will resolve your issue.
希望这将解决您的问题。