-
Notifications
You must be signed in to change notification settings - Fork 74
Plugin fails on OpenJDK 11.0.8 when using includeNoLocationClasses = true #193
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
Comments
I face the same issue in circle ci when compile with JDK11, i found that the root cause is this one (gradle/gradle#5184), i tried the solution ( |
the same problem |
adding this to my script did the trick :
|
@prolland Thanks so much for this! I was stuck on this for a while. I had the jacoco.excludes but i wasnt using that inside the afterEvaluate - that is the key! |
Hello, After making this change, I am getting zero coverage in the report. Any inputs here please? |
@vramasam I do have the same problem, but I believe it is due to the upgrade to android gradle plugin 4.2.0 and not jdk11 (both come with the same studio upgrade if I remember well). I had posted a comment here for that and I see there is another comment with a potential workaround. I tried and I now have code coverage again :
|
Hello all, Here I have not upgraded the Android plugin and I have just upgraded the Java version. Below are the steps I tired: After that I am getting coverage report is zero. |
Hello @prolland Any thoughts that would help me here? |
@vramasam No sorry nothing more.
|
@prolland Okay Thank you. But I am not sure above setting hold good for the AGP 7.0.0. Again it started zero coverage with AGP 7.0.0. |
I have a possible workaround for you: in my experience switching the Gradle JDK to Adopt OpenJ9 resolves this issue. In Android Studio: open settings > Build, Execution, Deployment > Build Tools > Gradle, change the Gradle JDK to |
Hello @mrgoltstein Thank you for the inputs. But as part of Android Gradle Plugin 7.0.0 , its mandatory to upgrade and use Java 11 for building the Android projects. so we cant downgraded the Java version. Also, If anyone have a workaround or proper fix with Java 11 and with AGP 7.0.0, please provide the inputs. |
Hi @vramasam I think the name of the SDK might be throwing you off here - |
@mrgoltstein Okay Thank you for the explanation. I have tried with OpenJ9 with Android Gradle plugin 7.0.1 but I have no luck, still its shows zero percentage coverage. |
For me, resolving the jdk classes issue required some additional changes in the above snippet. junitJacoco {
includeNoLocationClasses = true
}
subprojects {
afterEvaluate {
tasks.withType(Test) {
// fixes https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/193
it.jacoco.excludes = ['jdk.internal.*']
}
}
} |
@mrgoltstein The above solution worked finally with latest gradle version. Thank you |
I can't do the same for kotlin DSL jacoco seems to be defined but excludes is not a reference. exclude is in red
|
- For some reason subproject classes considered as noLocationClasses - Excluding internals required to avoid exception, see vanniktech/gradle-android-junit-jacoco-plugin#193 (comment)
The plugin fails with the below error when running
jacocoTestReport
, if using OpenJDK 11.0.8 (as included in Android Studio 4.2 RC1), and whenincludeNoLocationClasses = true
(which seemingly is required many common setups in order for coverage to be reported correctly.Steps
JAVA_HOME
to$ANDROID_STUDIO_PATH/Contents/jre/jdk/Contents/Home
(may vary depending on OS)./gradlew jacocoTestReportRelease
Expected
Build succeeds
Actual
Build fails
Error
Sample project
TestJacoco.zip
Environment
AGP
4.1.2
Plugin version
0.16.0
OpenJDK 11.0.8
The text was updated successfully, but these errors were encountered: