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

后端 未结 3 2018
囚心锁ツ
囚心锁ツ 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:19

    Reason: When the classpath dependency to perf-plugin is defined in the app-level build.gradle file instead of project-level build.gradle file, perf-plugin (at runtime) get's the ASM v6 dep even though in it's POM file ASM v7 dep is declared. This triggers the IllegalArgumentException in the perf-plugin v1.2.0 and v1.2.1 because they depend on ASM v7 however it works fine for v1.1.5 because it depend on ASM v6.

    There are a host of posts here that explain why the classpath of the top level buildscript is intended to be different from the rest of the project:


    Solution: This is gradle behavior. A quick solution to this is to define the perf-plugin dependency only in the root-project build.gradle (which is already mentioned in the public docs).


    Detailed Explanation:

    NO BUG

    root-project build.gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.4.1'
            classpath 'com.google.firebase:perf-plugin:1.2.1'
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    

    app-level build.gradle

    apply plugin: 'com.android.application'
    apply plugin: 'com.google.firebase.firebase-perf'
    
    
    . . .
    
    dependencies {
        implementation 'com.google.firebase:firebase-perf:17.0.2'
    }
    

    BUG

    root-project build.gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.4.1'
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    

    app-level build.gradle

    buildscript {
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.google.firebase:perf-plugin:1.2.1'
        }
    }
    
    apply plugin: 'com.android.application'
    apply plugin: 'com.google.firebase.firebase-perf'
    
    
    . . .
    
    dependencies {
        implementation 'com.google.firebase:firebase-perf:17.0.2'
    }
    

    Comparison of $ ./gradlew clean :buildEnvironment command on both cases shows that all the references to org.ow2.asm:asm:6.0 is converted to org.ow2.asm:asm:7.0 in case of No Bug but that didn't happened in the Bug case:

    NO BUG

    > Task :buildEnvironment
    
    ------------------------------------------------------------
    Root project
    ------------------------------------------------------------
    
    .  .  .
    
        +--- com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta04
    |    |    +--- org.ow2.asm:asm:6.0 -> 7.0
    |    |    +--- org.ow2.asm:asm-util:6.0 (*)
    |    |    +--- org.ow2.asm:asm-commons:6.0 (*)
    |    |    +--- org.jdom:jdom2:2.0.6
    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.0 -> 1.3.31 (*)
    |    |    \--- com.android.tools.build.jetifier:jetifier-core:1.0.0-beta04 (*)
    |    +--- com.google.protobuf:protobuf-java:3.4.0
    |    \--- com.google.protobuf:protobuf-java-util:3.4.0 (*)
    \--- com.google.firebase:perf-plugin:1.2.1
         \--- org.ow2.asm:asm:7.0
    

    BUG

    > Task :buildEnvironment
    
    ------------------------------------------------------------
    Root project
    ------------------------------------------------------------
    
    .  .  .
    
         +--- com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta04
         |    +--- org.ow2.asm:asm:6.0
         |    +--- org.ow2.asm:asm-util:6.0 (*)
         |    +--- org.ow2.asm:asm-commons:6.0 (*)
         |    +--- org.jdom:jdom2:2.0.6
         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.0 -> 1.3.31 (*)
         |    \--- com.android.tools.build.jetifier:jetifier-core:1.0.0-beta04 (*)
         +--- com.google.protobuf:protobuf-java:3.4.0
         \--- com.google.protobuf:protobuf-java-util:3.4.0 (*)
    

提交回复
热议问题