Execution data for class does not match in Jacoco when use the latest Sentry dependencies

44 views Asked by At

My test coverage was broken after I added the latest Sentry dependencies (7.6.0). I started receiving these errors for some of my classes:

[ant:jacocoReport] Classes in bundle 'app' do not match with execution data. For report generation the same class files must be used as at runtime.
[ant:jacocoReport] Execution data for class *** does not match.

After removing Sentry coverage works as should. Anyone faced with this issue?

Here is my jacoco configuration:

apply plugin: 'jacoco'

jacoco {
    toolVersion '0.8.11'
}

tasks.withType(Test).configureEach {
    jacoco.includeNoLocationClasses = true
    jacoco.excludes = ['jdk.internal.*']
}

project.afterEvaluate {
    tasks.register("defaultDebugCoverage", JacocoReport) {
        dependsOn("testDefaultDebugUnitTest")
        mustRunAfter('testDefaultDebugUnitTest')
        group = "Reporting"
        description = "Generate Jacoco coverage reports for the defaultDebug build."

        reports {
            html.required.set(true)
            xml.required.set(true)
        }

        def excludes = [
                '**/R.class',
                '**/R$*.class',
                '**/BuildConfig.*',
                '**/Manifest*.*',
                '**/*_Provide*Factory*.*',
                '**/*_ViewBinding*.*',
                '**/AutoValue_*.*',
                '**/R2.class',
                '**/R2$*.class',
                '**/*Directions$*',
                '**/*Directions.*',
                '**/*Binding.*'
        ]

        def jClasses = "${project.buildDir}/intermediates/javac/defaultDebug/classes"
        def kClasses = "${project.buildDir}/tmp/kotlin-classes/defaultDebug"
        def javaClasses = fileTree(dir: jClasses, excludes: excludes)

        def kotlinClasses = fileTree(dir: kClasses, excludes: excludes)

        classDirectories.from = files([javaClasses, kotlinClasses])
        def sourceDirs = ["${project.projectDir}/src/main/java", "${project.projectDir}/src/main/kotlin",
                          "${project.projectDir}/src/defaultDebug/java", "${project.projectDir}/src/defaultDebug/kotlin"]

        sourceDirectories.from = files(sourceDirs)

        executionData.from = files(["${project.buildDir}/jacoco/testDefaultDebugUnitTest.exec"])
    }
}

After some research, I found that Sentry can modify my classes. But I don't know how I can fix it.

0

There are 0 answers