方法预计是虚拟类型

时间:2016-09-21 10:11:04

标签: java android amazon-web-services push-notification aws-mobilehub

我尝试使用以下代码将我的AWS Mobile Hub示例项目中的AWSMobileClient.defaultMobileClient()初始化为我的测试项目:

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 个答案:

答案 0 :(得分:0)

我已将我的Google Play服务库版本从9.0.0更改为9.0.1并解决了它。