方法应为虚拟类型
Posted
技术标签:
【中文标题】方法应为虚拟类型【英文标题】:Method was expected to be of type virtual 【发布时间】:2016-09-21 10:11:04 【问题描述】:我尝试使用以下代码将 AWSMobileClient.defaultMobileClient()
从我的 AWS Mobile Hub 示例项目初始化到我的测试项目中:
if (AWSMobileClient.defaultMobileClient() == null)
Log.e("MainActivity", "Initializing AWS Mobile Client...");
final ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setUserAgent(AWSConfiguration.AWS_MOBILEHUB_USER_AGENT);
final IdentityManager identityManager = new IdentityManager(getApplicationContext(), clientConfiguration);
final AWSMobileClient awsClient =
new AWSMobileClient.Builder(getApplicationContext())
.withCognitoRegion(AWSConfiguration.AMAZON_COGNITO_REGION)
.withCognitoIdentityPoolID(AWSConfiguration.AMAZON_COGNITO_IDENTITY_POOL_ID)
.withIdentityManager(identityManager)
.withClientConfiguration(clientConfiguration)
.build();
AWSMobileClient.setDefaultMobileClient(awsClient);
当我在我的设备中打开应用程序时,我在 android Studio 中收到了以下错误日志:
09-21 13:01:34.596 28886-28886/com.intap.snspushtest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.intap.snspushtest, PID: 28886
java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'com.google.android.gms.iid.zzd' appears in /data/app/com.intap.snspushtest-1/base.apk)
at com.google.android.gms.iid.zzd.zzeC(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.amazonaws.mobile.push.GCMTokenHelper.<init>(GCMTokenHelper.java:44)
at com.amazonaws.mobile.AWSMobileClient.<init>(AWSMobileClient.java:121)
at com.amazonaws.mobile.AWSMobileClient.<init>(AWSMobileClient.java:24)
at com.amazonaws.mobile.AWSMobileClient$Builder.build(AWSMobileClient.java:101)
at com.intap.snspushtest.MainActivity.onCreate(MainActivity.java:43)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
行如下。 AWSMobileClient.java:121
this.gcmTokenHelper = new GCMTokenHelper(context, AWSConfiguration.GOOGLE_CLOUD_MESSAGING_SENDER_ID);
AWSMobileClient.java:24
public class AWSMobileClient
AWSMobileClient.java:101
return
new AWSMobileClient(applicationContext,
cognitoIdentityPoolID,
cognitoRegion,
identityManager,
clientConfiguration);
MainActivity.java:43
final AWSMobileClient awsClient =
new AWSMobileClient.Builder(getApplicationContext())
.withCognitoRegion(AWSConfiguration.AMAZON_COGNITO_REGION)
.withCognitoIdentityPoolID(AWSConfiguration.AMAZON_COGNITO_IDENTITY_POOL_ID)
.withIdentityManager(identityManager)
.withClientConfiguration(clientConfiguration)
.build();
我真的不明白我面临什么问题,所以请你帮帮我?
【问题讨论】:
【参考方案1】:我已将我的 Google Play 服务库版本从 9.0.0 更改为 9.0.1,它解决了这个问题。
【讨论】:
以上是关于方法应为虚拟类型的主要内容,如果未能解决你的问题,请参考以下文章
Webservice报错客户端发现响应内容类型为“application/json;charset=UTF-8”,但应为“text/xml”。