Status Update
Comments
gm...@gmail.com <gm...@gmail.com> #2
Also affected by this issue too. I think ScopedArtifact.CLASSES
should not be affected by enableAndroidTestCoverage
and feels it was done like this more as a workaround than by design, right?
Actually, it would be nice if InternalScopedArtifact.PRE_JACOCO_TRANSFORMED_CLASSES
, InternalArtifactType.CODE_COVERAGE
and InternalArtifactType.UNIT_TEST_CODE_COVERAGE
are promoted to public artifacts as well so 3rd party plugins will be able to consume them without requiring reflection or accessing implementation details.
In my case, I had a plugin that integrates AGP with jacoco-report-aggregation
test-report-aggregation
di...@google.com <di...@google.com>
zo...@gmail.com <zo...@gmail.com> #3
I'm honestly not sure what ScopedArtifact.CLASSES
is, but I am seeing similar error messages output to log when running unit tests.
I made a minimal reproducible example here:
On AGP 7.4.2 the test passes and no errors are output. On The AGP 8.0.0 the test still passes, but now I get Please supply original non-instrumented classes
type errors printed out.
je...@google.com <je...@google.com> #4
This is done on purpose AFAIR, we probably need to provide another public type with the non instrumented classes.
gm...@gmail.com <gm...@gmail.com> #5
That will be ideal. Actually, would you be open to considering all intermediates exposed as outgoing variants or to be public API? In my case, I wanted to extend support for androidTest
variant coverage. Uninstrumented classes are missing, but also a public artifact to fetch .exec
files. I managed to get a reference to it by reflection and expose the variant myself, but that's not good enough of a robust plugin.
je...@google.com <je...@google.com> #6
Micah, can you bump up this bug in your priority list, this is blocking some external plugins to properly support AGP 8.x
up...@gmail.com <up...@gmail.com> #7
bp...@atlassian.com <bp...@atlassian.com> #8
I can reproduce this by:
1. Create a new compose activity project in Android Studio ( AGP 8.1+)
2. Add a class to the project under src/main/java/...
3. Reference that class in an unit test
4. The test will run but the logs output quite a few errors realting to this
This is basically the setup that #3 above mentioned. In one of our production apps just one of the test files was 52MB from all the stack traces generated from this issue.
je...@google.com <je...@google.com>
mi...@google.com <mi...@google.com>
ne...@gmail.com <ne...@gmail.com> #10
Micah,
Or any other Googler working on this, how exactly was this fixed? New API?
mi...@google.com <mi...@google.com> #11
The ScopedArtifact.CLASSES was previously representing the Jacoco-instrumented classes, but the workflow was rearranged so that this artifact represents the classes before Jacoco-instrumentation. The Jacoco-instrumented classes are then stored in a new internal artifact.
zo...@gmail.com <zo...@gmail.com> #12
Hi team,
Thanks for the updates!
When would we expect to see this in production/available to test? The links being posted are Google internal. Is the fix associated with a specific AGP version or something?
ro...@gmail.com <ro...@gmail.com> #13
As far as I can see potentially in an alpha version of 8.3
mi...@google.com <mi...@google.com> #14
It should be available starting with Android Studio Iguana/AGP 8.3 C5. Updated the link above with the public change.
zo...@gmail.com <zo...@gmail.com> #15
I can confirm that this issue is fixed using AGP 8.3 alpha 11. Thanks for the fix/updates here!
gs...@gmail.com <gs...@gmail.com> #16
Any chance to get this fix backported to AGP 8.2 at least? Android Studio Iguana/AGP 8.3 seems to be still far away, and not having proper code coverage reports is a major issue.
mi...@google.com <mi...@google.com> #17
Hi, unfortunately the cutoff to backport to 8.2 has already passed, so this is not possible.
Description
In Android Gradle Plugin 8.0 the new artifact
ScopedArtifact.CLASSES
returns classes (when usingtoGet()
that are already instrumented by JaCoCo when enabling test coverage usingenableUnitTestCoverage true
orenableAndroidTestCoverage true
.This is potentially a bug as it does not allow users of
ScopedArtifact.CLASSES
to provide non-instrumented classes to for example theJacocoReport
task (org.gradle.testing.jacoco.tasks.JacocoReport.classDirectories
).MultipleArtifact.ALL_CLASSES_DIRS
did not have this behavior.I can reproduce this also on AGP
8.1.0-beta01
Reproduce
ScopedArtifact.CLASSES
withtoGet()
I created a Minimal Reproducible Example here:https://github.com/Rolf-Smit/Android-ScopedArtifacts-with-JaCoCo
With the sample project the problem can be reproduced in at least 2 ways:
app:debugGetAllClasses
which should thrown an error sayingTestClassUnderTest.test_add()
, which will complete successfully but Android Studio will show the following trace:Version information:
Build #AI-223.8836.35.2231.9923731, built on April 12, 2023
8.0.1 (also on 8.0.0 and 8.1.0-beta01)
8.0
1.8 compatibility Java 17