java.lang.NoSuchFieldException error from jacoco

We Are Going To Discuss About java.lang.NoSuchFieldException error from jacoco. So lets Start this Java Article.

java.lang.NoSuchFieldException error from jacoco

  1. java.lang.NoSuchFieldException error from jacoco

    I was missing the following from my build.gradle:
    jacoco { toolVersion = "0.8.6" }
    While obvious, build.gradle can inherit properties from other gradle files and for reasons I can't figure out, jacoco was passing through in to one subproject but not to another.

  2. java.lang.NoSuchFieldException error from jacoco

    I was missing the following from my build.gradle:
    jacoco { toolVersion = "0.8.6" }
    While obvious, build.gradle can inherit properties from other gradle files and for reasons I can't figure out, jacoco was passing through in to one subproject but not to another.

Solution 1

I was missing the following from my build.gradle:

jacoco {
    toolVersion = "0.8.6"
}

While obvious, build.gradle can inherit properties from other gradle files and for reasons I can’t figure out, jacoco was passing through in to one subproject but not to another.

Original Author Of This Content

Solution 2

Ensure you are using JDK-11,
if using maven, ensure;

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

Ensure you are using latest jacoco.

        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.4</version>

Original Author Of This Content

Solution 3

Fixed this error changing Java SDK in my project from 14 to 11 and my tests started working fine.

Solution:
IntellijIDEA: File > Project Structure > Project Tab > SDK adopt-opendjdk-11 (in my case for Ubuntu).

Oh! Make sure Gradle Settings are also using the same JVM!
enter image description here
enter image description here

Hope that helps someone out there.

Original Author Of This Content

Solution 4

The issue comes from the Java version which needs not to be too recent.

sdk install java 19.3.0.2.r8-grl

makes things ok.

Original Author Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment