Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CrashlyticsCore: Expected method missing: registerOnMeasurementEventListener

I've set up Crashlytics for Android adding the dependencies in the gradle files. I use Crashlytics.logException(exception); to log exceptions. Crashlytics got activated in the Firebase console after the app threw an Exception on purpose to try things out, but no event was detected and no log appeared, so the console shows 0 crashes. In the same time the LogCat shows the following:

I/CrashlyticsCore: Initializing Crashlytics 2.6.1.23
I/CrashlyticsInitProvider: CrashlyticsInitProvider initialization successful
W/CrashlyticsCore: Expected method missing: registerOnMeasurementEventListener
    java.lang.NoSuchMethodException: parameter type is null
        at java.lang.Class.getMethod(Class.java:656)
        at java.lang.Class.getDeclaredMethod(Class.java:626)
        at com.crashlytics.android.core.DefaultAppMeasurementEventListenerRegistrar.invoke(DefaultAppMeasurementEventListenerRegistrar.java:89)
        at com.crashlytics.android.core.DefaultAppMeasurementEventListenerRegistrar.register(DefaultAppMeasurementEventListenerRegistrar.java:54)
        at com.crashlytics.android.core.CrashlyticsController.registerAnalyticsEventListener(CrashlyticsController.java:1574)
        at com.crashlytics.android.core.CrashlyticsCore.doInBackground(CrashlyticsCore.java:320)
        at com.crashlytics.android.core.CrashlyticsCore.doInBackground(CrashlyticsCore.java:44)
        at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63)
        at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28)
        at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:311)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:818)
I/CrashlyticsCore: Crashlytics report upload complete: 5ABA789603A5-0001-7C52-7AF6D12C00C8

Why is the registerOnMeasurementEventListener method missing; I have only a default proguard-rules.pro file with the following:

UPDATED:

-assumenosideeffects class android.util.Log {
    public static int d(...);
}

############ Crashlytics ################################
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
like image 945
Galya Avatar asked Mar 27 '18 17:03

Galya


2 Answers

Expanding on what several have already said before, it is sufficient to add this to you proguard.cfg:

-keep class com.google.android.gms.measurement.AppMeasurement { *; }
-keep class com.google.android.gms.measurement.AppMeasurement$OnEventListener { *; }

The only reason this is necessary is that Fabric references these two classes by reflection and proguard doesn't detect that.

like image 183
Ben Sandee Avatar answered Sep 27 '22 00:09

Ben Sandee


I was having the same problem and I just find the solution... So, looking at the stacktrace, it says the problem is that the method registerOnMeasurementEventListener is not found, right? But it doesn't say where.

Looking at the decompiled code for that class DefaultAppMeasurementEventListenerRegistrar. It shows that the method is being called from the class:

Class onEventListenerClass = this.getClass("com.google.android.gms.measurement.AppMeasurement$OnEventListener");

So, I just added the extra following to the proguard file:

-keep class com.google.android.** { *; }

And it worked, the warning is gone. I guess I could have added the specific class instead of all under com.google.android but my thought process was: I might not want to touch any Android classes as this same problem might present for other libraries or other code.

Anyway, I hope this help you or it might help some other people having the same issue. Cheers!

like image 24
Hugo Allexis Cardona Avatar answered Sep 23 '22 00:09

Hugo Allexis Cardona