错误:任务':app:transformClassesWithFirebasePerformancePluginForRelease'的执行失败

fil*_*lol 11 java android firebase firebase-performance

在发布模式下编译时,找不到此错误的起因。我的印象是,此错误未修改我的代码就出现了(我尝试回溯到github,但仍然有此错误)。

错误:任务':app:transformClassesWithFirebasePerformancePluginForRelease'的执行失败。

java.io.IOException:找不到指定的路径

带有调试标志的Gradle

22:36:11.767 [ERROR] [FirebasePerformancePlugin]无法检测org / apache / xmlbeans / impl / schema / SchemaTypeSystemCompiler.class

我的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven {
            url 'https://maven.google.com'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
        classpath 'com.google.firebase:firebase-plugins:1.1.0'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'http://www.idescout.com/maven/repo/'
        }
        maven {
            url 'https://maven.google.com'
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的app / build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'

android {

    compileSdkVersion 26
    buildToolsVersion '26.0.0'
    defaultConfig {
        applicationId ""
        minSdkVersion 16
        targetSdkVersion 26
        multiDexEnabled true

        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
            signingConfig signingConfigs.Keys
        }
        debug {
            signingConfig signingConfigs.Keys
        }
    }
    dexOptions {
        jumboMode = true
    }

    packagingOptions {
        pickFirst 'META-INF/*'
    }
}

repositories {
    jcenter()
}
repositories {
    maven { url "http://repo1.maven.org/maven2" }
    maven { url 'https://jitpack.io' }
    maven { url 'https://maven.fabric.io/public' }
}

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.android.support:appcompat-v7:26.0.0-beta2'
    compile 'com.android.support:support-v13:26.0.0-beta2'
    compile 'com.android.support:support-v4:26.0.0-beta2'
    compile 'com.android.support:design:26.0.0-beta2'
    compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:cardview-v7:26.0.0-beta2'
    compile 'com.android.support:customtabs:26.0.0-beta2'

    //firebase
    compile 'com.google.firebase:firebase-ads:11.0.2'
    compile 'com.google.firebase:firebase-core:11.0.2'
    compile 'com.google.firebase:firebase-messaging:11.0.2'
    compile 'com.google.firebase:firebase-auth:11.0.2'
    compile 'com.google.firebase:firebase-database:11.0.2'
    compile 'com.google.firebase:firebase-config:11.0.2'
    compile 'com.google.firebase:firebase-storage:11.0.2'
    compile 'com.google.firebase:firebase-perf:11.0.2'
    compile 'com.firebaseui:firebase-ui-auth:1.2.0'

    //Fabric
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }


    compile 'com.android.support:support-vector-drawable:26.0.0-beta2'
    compile 'commons-io:commons-io:2.5'

    compile 'com.android.support:multidex:1.0.1'
    compile files('libs/aa-poi-ooxml-schemas-3.10-reduced-more-0.1.5.jar')
    compile files('libs/aa-poi-3.10-min-0.1.5.jar')
}

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

Sve*_*obs 6

将我的Android项目迁移到Gradle Kotlin DSL后,我突然还收到Can't instrument了Firebase Performance Plugin 对该项目的任何类(包括第三方依赖项)产生的错误。构建最终会因终止OutOfMemoryError。错误是

Can't instrument: ...
java.lang.IllegalArgumentException
        at org.objectweb.asm.ClassVisitor.<init>(ClassVisitor.java:79)
        at com.google.firebase.perf.plugin.instrumentation.InstrumentationVisitor.<init>(InstrumentationVisitor.java:55)
        ...
Run Code Online (Sandbox Code Playgroud)

查看ASM的ClassVisitor的源代码,我看到IllegalArgumentException当传递未处理的api版本时,在构造函数中引发了该错误。perf-plugin需要7.0版的ASM。但是,当./gradlew :app:dependencies我检查项目依赖性时,发现使用的是ASM 6.0版本。显然,某些其他依赖项需要6.0。

我试图用以下方式显式覆盖ASM依赖项

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

./gradlew :app:dependencies我的输出中,我现在看到使用了7.0,但是我仍然收到此错误:(

更新:降级com.google.firebase:firebase-plugins1.2.01.1.5解决这个问题对我来说。

更新2:的2.0.0版本,firebase-plugins它的使用过时。现在推荐的解决方案是显式使用Performance Monitoring插件。迁移到新插件后,现在为我解决了问题。

更新3:我必须撤回之前的声明。使用Performance Monitor插件确实可以在本地计算机上修复该构建,但不能在我的Jenkins构建服务器上修复该构建。同样,将configurations.all上面提到的块移到buildscriptAntimonit注释的块中也无法修复该构建,尽管在输出中可以看到./gradlew buildEnvironmentASM 7.0用于构建。