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

时间:2017-07-18 16:10:49

标签: java android firebase firebase-performance

在发布模式下编译时,找不到此错误的来源。我的印象是这个错误出现而没有修改我的代码(我尝试回到github,但我仍然有这个错误)。

  

错误:任务执行失败   ':应用程序:transformClassesWithFirebasePerformancePluginForRelease'。

     
    

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

  

Gradle with debug flag

22:36:11.767 [错误] [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'
        }
    }
}

我的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'

3 个答案:

答案 0 :(得分:4)

将我的Android项目迁移到Gradle Kotlin DSL之后,我突然还收到Firebase Performance Plugin针对项目的 any 类(包括第三方依赖项)产生的Can't instrument错误。该构建最终会以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)
        ...

查看ASM的ClassVisitor的源代码,我看到在传递未处理的api版本时,在构造函数中抛出了IllegalArgumentExceptionperf-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")
        }
    }
}

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

更新:将com.google.firebase:firebase-plugins1.2.0降级为1.1.5为我解决了这个问题。

答案 1 :(得分:1)

原因: 当在{strong>应用级 perf-plugin文件而不是项目级 build.gradle文件中定义了对build.gradle的类路径依赖项时,{ {1}}(在运行时)即使声明为POM file ASM v7 dep,也得到 ASM v6 部门。这会触发perf-plugin perf-pluginv1.2.0中的 IllegalArgumentException ,因为它们依赖 ASM v7 ,但是对于{{1 }},因为它取决于 ASM v6

有很多帖子here解释了为什么顶级buildscript的类路径与项目的其余部分不同:


解决方案: 这是gradle行为。一种快速的解决方案是仅在 root-project v1.2.1(在public docs中已经提到)中定义v1.1.5依赖项。


详细说明:

没有错误

根项目build.gradle

perf-plugin

应用程序级build.gradle

build.gradle

错误

根项目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()
    }
}

应用程序级build.gradle

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


. . .

dependencies {
    implementation 'com.google.firebase:firebase-perf:17.0.2'
}

在两种情况下,// 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() } } 命令的比较表明,在无错误的情况下,所有对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' } 的引用都转换为$ ./gradlew clean :buildEnvironment,但这没有发生在 Bug 案例中:

没有错误

org.ow2.asm:asm:6.0

错误

org.ow2.asm:asm:7.0

答案 2 :(得分:0)

我有同样的错误,因为我的buildSrc目录包含gradle android junit jacoco plugin的分支。一旦我摆脱了(实际上我已经通过依赖原始插件替换了源代码fork),错误就消失了。如果以上建议都不能帮助您,请尝试检查您的buildSrc目录。

相关问题