Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError | JaCoCo Offline Code Coverage | Gradle -Android #1163

Open
rajb865 opened this issue Jul 26, 2023 · 0 comments

Comments

@rajb865
Copy link

rajb865 commented Jul 26, 2023

JaCoCo Tool Version - 0.8.6
Gradle Version - gradle-6.8.3
java Version - 11
Android Studio version - Android Studio Flamingo | 2022.2.1 Patch 2
Windows - Windows 10 (22H2)

I am using jacoco_offline.gradle file to generate the code coverage for an android project. When I run all of my test cases without JaCoCo, they are executing successfully. When I am running this ./gradlew createOfflineTestCoverageReport jacocoTestReport command in the root directory of my project, I am getting the below errors in all of my test cases

com.example.android.myproject.MyClassTest > test_updateProperties_Negative FAILED
    java.lang.NoClassDefFoundError at null:-1

in jacoco_offline.gradle file I see this block of code

gradle.taskGraph.whenReady { graph ->
    if (graph.hasTask(instrument)) {
        tasks.withType(Test) {
            doFirst {
                systemProperty 'jacoco-agent.destfile', buildDir.path + '/jacoco/testDebugUnitTest.exec'
                classpath = files(offline_instrumented_outputDir) + classpath + configurations.jacocoRuntime
            }
        }
    }
}

when I comment classpath = files(offline_instrumented_outputDir) + classpath + configurations.jacocoRuntime line in above code then my build works fine but I get the code coverage % as zero.

Could you suggest my if there is any problem with my configuration or it is a bug in JaCoCo offline code coverage?

Thanks,
Raj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant