0

我尝试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();

我真的不明白我面临什么问题,所以你能帮我吗?

4

1 回答 1

0

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

于 2016-09-21T10:29:19.057 回答