suku suku - 1 month ago 103
Android Question

InvocationTargetException on FCM message received caused by NoSuchMethodError

When a FCM message is sent to the device. I crashes with InvocationTargetException caused by NoSuchMethodError.

Caused by: java.lang.NoSuchMethodError: No static method zzz(Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzaa; or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa' appears in /data/data/com.dodum.ahivelnr/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-9.6.1_edeb30b4cf5821e3a8ccd94cce4eee06ac81c766-classes.dex)
at com.google.android.gms.measurement.internal.zzx.zzbd(Unknown Source)
at com.google.android.gms.measurement.AppMeasurement.getInstance(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method) 
at com.google.firebase.FirebaseApp.zza(Unknown Source) 
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723) 
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
at android.app.ActivityThread.installProvider(ActivityThread.java:5197) 
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4792) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4732) 
at android.app.ActivityThread.-wrap1(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5461) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 


I am using latest FCM:
com.google.firebase:firebase-messaging:9.6.1

Also the latest gradle: com.android.tools.build:gradle:2.2.1

I have added
classpath 'com.google.gms:google-services:3.0.0'


I have added plugin
apply plugin: 'com.google.gms.google-services'

Answer

As far as I know, this error occurs when Firebase Instance ID services dependency is not properly implemented. Make sure your manifest is proper and apply plugin: 'com.google.gms.google-services' is declared outside at the bottom of dependencies.