I am attaching error log here ...
E/AndroidRuntime: FATAL EXCEPTION: IntentService[RNPushNotification]
Process: com.shafi.app, PID: 4463
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.shafi.app/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-9.8.0_e816c785e83e97704fbd262674378e0e6ad734ab-classes.dex)
at com.google.android.gms.iid.zzd.zzkq(Unknown Source)
at com.google.android.gms.iid.zzd.
at com.google.android.gms.iid.zzd.
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService.onHandleIntent(RNPushNotificationRegistrationService.java:22)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:67)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
It's because the react-native-push-notifications uses the 'com.google.android.gms:play-services-gcm:9.4.0' dependency, which you need to add in your build.gradle file under your android/app/ folder.
dependencies {
compile "com.facebook.react:react-native:+"
compile 'com.google.android.gms:play-services-gcm:+'
}
version used in library is compile 'com.google.android.gms:play-services-gcm:+' so i have changed it to compile 'com.google.android.gms:play-services-gcm:10.0.1' and same version in my android/app/build.gradle also.
But still it is showing same error :
java.lang.NoSuchMethodError: No static method
getNoBackupFilesDir(Landroid/content/Context;)Ljava/io/File; in class
Lcom/google/android/gms/common/util/zzw; or its super classes (declaration of
'com.google.android.gms.common.util.zzw' appears in /data/app/com.anne-xJfPRlFGyCcin1b-
S5YQhg==/base.apk)
at com.google.android.gms.iid.zzd.zzeK(Unknown Source:2)
at com.google.android.gms.iid.zzd.<init>(Unknown Source:32)
at com.google.android.gms.iid.zzd.<init>(Unknown Source:2)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source:22)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source:1)
at com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService.onHandleIntent(RNPushNotificationRegistrationService.java:24)
Beside @MatthiasDebaere suggestion, I also had to use this to make it work
implementation (project(':react-native-push-notification')) {
exclude group: "com.google.android.gms"
}
P/S: I'm using com.android.tools.build:gradle:3.1.0
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.
Most helpful comment
It's because the react-native-push-notifications uses the 'com.google.android.gms:play-services-gcm:9.4.0' dependency, which you need to add in your build.gradle file under your android/app/ folder.