Error:Execution failed for task ':app:transformClassesWithFirebasePerformancePluginForRelease'

后端 未结 3 2022
囚心锁ツ
囚心锁ツ 2021-02-13 14:39

I can not find the origin of this error when I compile in release mode. I have the impression that this error appeared without modifying my code (I try to go back with github bu

3条回答
  •  执念已碎
    2021-02-13 15:31

    After migrating my Android project to Gradle Kotlin DSL I suddenly also receive the Can't instrument error by the Firebase Performance Plugin for any class of the project, including third-party dependencies. The build eventually aborts with an OutOfMemoryError. The error is

    Can't instrument: ...
    java.lang.IllegalArgumentException
            at org.objectweb.asm.ClassVisitor.(ClassVisitor.java:79)
            at com.google.firebase.perf.plugin.instrumentation.InstrumentationVisitor.(InstrumentationVisitor.java:55)
            ...
    

    Looking at the source code of ASM's ClassVisitor I see that IllegalArgumentException is thrown in the constructor when an unhandled api version is passed. perf-plugin requires version 7.0 of ASM. However when checking the project dependencies with ./gradlew :app:dependencies I find out that version 6.0 of ASM is used. Obviously some other dependency requires 6.0.

    I tried to explicitly overwrite the ASM dependency with

    configurations.all {
        resolutionStrategy.eachDependency {
            if (requested.group == "org.ow2.asm") {
                useVersion("7.0")
                because("Version required by Firebase Performance Plugin")
            }
        }
    }
    

    and in the output of ./gradlew :app:dependencies I now see that 7.0 is used but I still receive this error :(

    Update: Downgrading com.google.firebase:firebase-plugins from 1.2.0 to 1.1.5 solves the problem for me.

    Update 2: As of version 2.0.0 of firebase-plugins its usage is deprecated. The recommended solution is now to use the Performance Monitoring plugin explicitly. After migrating to the new plugin the problem is now solved for me.

    Update 3: I must withdraw my previous statement. Using the Performance Monitor plugin did fix the build on my local machine but not on my Jenkins build server. Also moving the configurations.all block mentioned above into the buildscript block as commented by Antimonit did not fix the build, although I can see in the output of ./gradlew buildEnvironment that ASM 7.0 is used for the build.

提交回复
热议问题