Problems implementing the new GCM Client for Android

前端 未结 2 1626
悲哀的现实
悲哀的现实 2020-12-19 08:39

I\'m trying to implement the new GCM Client on Android following the guidelines from Google (https://developers.google.com/cloud-messaging/android/client). I\'m

相关标签:
2条回答
  • 2020-12-19 09:07

    I saw that the method getNoBackupFilesDir is found in android.support.v4.content.ContextCompat.

    Seems that the problem was that I had an old appcompat-v7 included in the project. Download with the SDK manager the last version of Android Support Library and then follow the steps for Adding libraries with resources and add the library to your application project.

    0 讨论(0)
  • 2020-12-19 09:24

    I got this error:

    java.lang.NoSuchMethodError: No static method getNoBackupFilesDir(Landroid/content/Context;)Ljava/io/File; in class Lcom/google/android/gms/common/util/zzx; or its super classes (declaration of 'com.google.android.gms.common.util.zzx' appears in /data/data/com.crave.iapdemo/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-10.0.1_b9da1447b99cc6cbc2fa601fb84d0418780bfa55-classes.dex)
                                                                           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 vodio.labs.crave.gcm.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:39)
    

    in this line:

    InstanceID.getInstance(this);
    

    The solution for me was upgrading this:

    dependencies {
        // play services
        compile 'com.google.android.gms:play-services-gcm:9.0.0'
        compile 'com.google.android.gms:play-services-analytics:9.0.0'
    }
    

    into:

    dependencies {
        // play services
        compile 'com.google.android.gms:play-services-gcm:10.0.1'
        compile 'com.google.android.gms:play-services-analytics:10.0.1'
    }
    
    0 讨论(0)
提交回复
热议问题