Status Update
Comments
vi...@google.com <vi...@google.com>
tr...@block.xyz <tr...@block.xyz> #2
tr...@block.xyz <tr...@block.xyz> #3
Analyzing dynamic features on their own like that doesn't work properly since even though they "depend" on the app they're actually including into an app so for example the unused resource check only makes sense when you look at it from the app perspective, not the other way around.
I believe in 7.0 we've fixed this in the sense that there isn't a lint task on the individual dynamic features.
tr...@block.xyz <tr...@block.xyz> #4
+1. In AGP 7.0 there are no lint tasks in dynamic-features; instead, any dynamic-features are analyzed when running lint on the app module. OP, can you try with AGP 7.0.0-rc01
, run lintRelease
on the corresponding application module, and see if you still hit the same issue?
tr...@block.xyz <tr...@block.xyz> #5
Not using dynamic feature modules but have this with an application module and a library module, happening on 7.0.0-rc01. I haven't figured out a repro yet but will upload one if I manage.
tr...@block.xyz <tr...@block.xyz> #6
Re #5, yes, a repro project would be very helpful, thanks!
je...@google.com <je...@google.com>
ga...@google.com <ga...@google.com> #7
Closing this bug as not reproducible, but please reopen if you have a repro project.
ga...@google.com <ga...@google.com> #8
Here is project that reproduces the issue. Running ./gradlew aDAT
creates android test APK with missing classes.
tr...@block.xyz <tr...@block.xyz> #9
Thanks for investigating and reproducing it so quickly! Let me know if I can help further. I very much want to understand this issue.
ga...@google.com <ga...@google.com> #10
Running ./gradlew :lib:outgoingVariants
there is
Secondary variants (*)
- Variant : classes
- Attributes
- org.gradle.category = library
- org.gradle.dependency.bundling = external
- org.gradle.jvm.version = 8
- org.gradle.libraryelements = classes
- org.gradle.usage = java-runtime
- org.jetbrains.kotlin.localToProject = public
- org.jetbrains.kotlin.platform.type = jvm
- Artifacts
- build/classes/java/main (artifactType = java-classes-directory)
- build/classes/kotlin/main (artifactType = java-classes-directory)
and this results in having ArtifactCollection.getArtifactFiles()
return both files, but ArtifactCollection.getArtifacts()
returns only 1 artifact. As already mentioned in previous comments, we can probably fix this in SubtractingArtifactCollection
in AGP.
The issue is triggered when application consumes kotlin-only module and desugaring is not needed (either using java 7 lang level or deploying to device with API 24+).
tr...@block.xyz <tr...@block.xyz> #11
Is it expected for ArtifactCollection.getArtifacts()
to return only 1 artifact, when there are two? Meaning, is Gradle working as intended?
tr...@block.xyz <tr...@block.xyz> #12
FWIW, I had a slightly different output from running outgoingVariants
--------------------------------------------------
Variant apiElements
--------------------------------------------------
Description = API elements for main.
Capabilities
- register.common.rx2-utilities-jvm:testing:unspecified (default capability)
Attributes
- org.gradle.category = library
- org.gradle.dependency.bundling = external
- org.gradle.jvm.version = 8
- org.gradle.libraryelements = jar
- org.gradle.usage = java-api
- org.jetbrains.kotlin.localToProject = public
- org.jetbrains.kotlin.platform.type = jvm
Artifacts
- build/libs/testing.jar (artifactType = jar)
Secondary variants (*)
- Variant : classes
- Attributes
- org.gradle.category = library
- org.gradle.dependency.bundling = external
- org.gradle.jvm.version = 8
- org.gradle.libraryelements = classes
- org.gradle.usage = java-api
- org.jetbrains.kotlin.localToProject = public
- org.jetbrains.kotlin.platform.type = jvm
- Artifacts
- build/classes/java/main (artifactType = java-classes-directory)
- build/classes/kotlin/main (artifactType = java-classes-directory)
- build/classes/kotlin/main (artifactType = java-classes-directory)
I'm not 100% sure why my build shows three artifacts vs your two, but I suspect it's because my build has two separate packages in the Kotlin source (i.e., more than one Kotlin source file, in different packages), whereas yours only has one Kotlin source file.
ga...@google.com <ga...@google.com> #13
tr...@block.xyz <tr...@block.xyz> #14
FYI, we also see this issue in a slightly different context, which results in flaky builds, rather than deterministically-incorrect builds. Here's the module with multiple artifacts:
Secondary variants (*)
- Variant : classes
- Attributes - org.gradle.category = library
- org.gradle.dependency.bundling = external
- org.gradle.jvm.version = 8
- org.gradle.libraryelements = classes
- org.gradle.usage = java-api
- org.jetbrains.kotlin.localToProject = public
- org.jetbrains.kotlin.platform.type = jvm
- Artifacts
- build/classes/java/main (artifactType = java-classes-directory)
- build/classes/kotlin/main (artifactType = java-classes-directory)
- build/classes/kotlin/main (artifactType = java-classes-directory)
This module only has Kotlin source, but it also uses Dagger, so there is generated code.
After one first build (./gradlew :path:to:module:assembleDebugAndroidTest
), I inspected the resultant test APK:
$ find bad -type f -name "NoopTmn*"
bad/smali_classes2/com/squareup/tmn/NoopTmnTimings_Factory.smali
bad/smali_classes2/com/squareup/tmn/NoopTmnTimings_Factory$InstanceHolder.smali
I know the name is meaningless to you, but it's missing the class NoopTmnTimings.smali
.
After re-running that build, I get a different artifact:
$ find new -type f -name "NoopTmn*"
new/smali_classes2/com/squareup/tmn/NoopTmnTimings_Factory.smali
new/smali_classes2/com/squareup/tmn/NoopTmnTimings.smali
new/smali_classes2/com/squareup/tmn/NoopTmnTimings_Factory$InstanceHolder.smali
So, this is flaky. Sometimes I get the expected file, other times I don't.
I can't explain why this is flaky, but we are hopeful that AGP 4.2.2 will also resolve this issue. We suspect/are irrationally worried it's related to the build cache somehow.
ga...@google.com <ga...@google.com> #15
This is now fixed in studio-main and also cherry-picked to 4.2 and 7.0 branches.
You can also work around this issue by having your own version of SubtractingArtifactCollection
in buildSrc
which has this fix -
tr...@block.xyz <tr...@block.xyz> #16
Yup, we've already patched it locally :)
ko...@gmail.com <ko...@gmail.com> #17
steamkar id,sappowt
Description
Build: AI-202.7660.26.42.7322048, 202104290118,
AI-202.7660.26.42.7322048, JRE 11.0.8+10-b944.6916264x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.16, screens 3440x1440
AS: 4.2; Kotlin plugin: 202-1.4.32-release-AS8194.7; Android Gradle Plugin: (plugin information not found); Gradle: 6.8.3; NDK: from local.properties: (not specified), latest from SDK: (not found); LLDB: pinned revision 3.1 not found, latest from SDK: (package not found); CMake: from local.properties: (not specified), latest from SDK: (not found), from PATH: 3.19.3
IMPORTANT: Please readhttps://developer.android.com/studio/report-bugs.html carefully and supply all required information.
We have a structure roughly as follows:
Where
ObserverFix.java
is an interface:and
Impl.kt
hasIf I run this incantation with AGP 4.1.3:
and then I inspect the resultant apk with apktool like
I can see that both
Impl
andObserverFix
are in the apk. If I run the Gradle incantation again with 4.2.0, then onlyObserverFix
is in the apk --Impl
is nowhere to be found (and the test fails at runtime).If I remove
ObserverFix
and makeImpl
compilable, and then run Gradle again with AGP 4.2.0, thenImpl
is in the APK again.So, my suspicion is that this has something to do with the mixed source set, but it's just speculation.
Finally, one of my colleagues was able to figure out which version of 4.2 produced the issue. He tells me that he cannot reproduce this issue with 4.2.0-alpha07, but can repro it with 4.2.0-alpha08. The diff, unfortunately, is huge.