Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Performance Monitoring, Can't instrument...IllegalArgumentException

I'm using implementation 'com.google.firebase:firebase-perf:19.0.5'

I applied the plugin: apply plugin: 'com.google.firebase.firebase-perf'

and in my project level gradle: classpath 'com.google.firebase:perf-plugin:1.3.1'

I'm running into a few issues. 1) during my build, I see a lot of Can't instrument exceptions like this:

Can't instrument: kotlin/reflect/jvm/internal/impl/load/java/lazy/descriptors/LazyJavaClassMemberScope$nestedClasses$1$enumMemberNames$1.class
java.lang.IllegalArgumentException
        at org.objectweb.asm.ClassVisitor.<init>(ClassVisitor.java:79)
        at com.google.firebase.perf.plugin.instrumentation.InstrumentationVisitor.<init>(InstrumentationVisitor.java:55)
        at com.google.firebase.perf.plugin.instrumentation.Instrument.instrument(Instrument.java:170)
        at com.google.firebase.perf.plugin.instrumentation.Instrument.instrumentClassesInJar(Instrument.java:117)
        at com.google.firebase.perf.plugin.FirebasePerfTransform.performTransformationFor(FirebasePerfTransform.java:563)
        at com.google.firebase.perf.plugin.FirebasePerfTransform.transformJarInputs(FirebasePerfTransform.java:445)
        at com.google.firebase.perf.plugin.FirebasePerfTransform.transform(FirebasePerfTransform.java:416)
        at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
        at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
        at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)
        at sun.reflect.GeneratedMethodAccessor190.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
        at

2) I only see logging TraceMetric and no NetworkRequestMetric. the API calls are using Retrofit2, which uses OkHttp3

like image 788
Jia Tse Avatar asked Nov 15 '22 15:11

Jia Tse


1 Answers

I had the same issue, and the fix was to move the classpath of the firebase performance before the other plugin that has the dependency to the "org.ow2.asm:asm"(in the project level gradle file).

  dependencies {
    classpath 'com.google.firebase:perf-plugin:1.3.1'
    classpath "org.jacoco:org.jacoco.core:$jacoco_version"
    ...
 }

Firebase plugin uses version 7.0 of the org.ow2.asm:asm Jacoco plugin uses 5.+ of the org.ow2.asm:asm

To check the versions you can try to use ./gradlew buildEnvironment

https://www.gitmemory.com/issue/gradle/gradle/9650/499815877

Maybe you have the same issue as me.

like image 100
Protiuc Andrei Avatar answered May 16 '23 06:05

Protiuc Andrei