Status Update
Comments
bi...@google.com <bi...@google.com>
jv...@google.com <jv...@google.com>
ga...@google.com <ga...@google.com>
au...@google.com <au...@google.com> #2
Lint options:
lintOptions {
lintConfig = file('lint.xml')
abortOnError true
xmlReport true
htmlReport true
checkDependencies true
}
Also, our project has custom lint rules. Failure happens with a dependency of 26.6.3 and 27.0.0.
Is any way to downgrade lint runner? This problem is keeping us from using AGP 4.0
bi...@google.com <bi...@google.com> #3
Attached slightly different stacktrace for the same problem.
Wonder if disabling some lint rules could help to "fix" this problem, as it is also blocking for us 4.0 AGP upgrade.
au...@google.com <au...@google.com> #4
Notes:
I suspect the exceptions are happening now because JetBrains recently changed an assert
statement into a hard failure (see
I.e., it's possible that Lint has been hitting this code path all along, and only now it is causing a problem.
This has been difficult to investigate so far because the failure is nondeterministic and also deep inside the Kotlin compiler. Plus, JetBrains seems to be hitting this code path occasionally too (hence why they changed the assert into a hard failure), so I'm not even sure whether Lint is implicated or not.
bi...@google.com <bi...@google.com> #5
It could also explain why not all lint rules were working from time to time (
Is any public issue created I could follow?
ga...@google.com <ga...@google.com> #6
Has anyone tried this with 4.1.0-beta2? We're using a more recent version of UAST and the Kotlin compiler there. It's not clear that it's fixed but -- there's a chance :-)
bi...@google.com <bi...@google.com> #7
I tried. The same error. I am wondering, is any way to know which lint checks cause failure? I have a few custom lint checks. Or, is any way downgrade compiler for lint checks?
sp...@google.com <sp...@google.com> #8
I did more tests and probably narrow down a cause. I did all tests on 4.1.0-beta2
. Original configuration have enabled checkDependencies
and included custom lint checks. Custom lint checks are compiled using 26.6.3
version:
checkDependencies = true, customLintChecks = true
= 20% chance of successcheckDependencies = true, customLintChecks = false
= 57% chance of successcheckDependencies = false, customLintChecks = true
= 100% chance of success
It is a clear evidence that checkDependencies
feature is not stable. In addition, custom lint checks is not friendly with checkDependencies
and increases the risk of failure. Or maybe just an old lint SDK used is to blame.
It is very similar to
I have a theory, but do not know how to test. Maybe crashes happening because there are some lint checks from libs built upon old lint SDK version?
sp...@google.com <sp...@google.com> #9
To me this is happening on 4.2.0-alpha04 too.
Can someone confirm that this is happening if you have these three conditions met?:
- checkDependencies=true on your app module
- have a custom lint rule using lintChecks on your app module
- have a custom lint rule using lintChecks on your library module
For me the error went away after I removed the lintChecks on the library module.
xa...@google.com <xa...@google.com> #10
could you clarify exactly what you mean in these?
have a custom lint rule using lintChecks on your app module have a custom lint rule using lintChecks on your library module
By this I mean a declaration in your modules dependency block:
lintChecks project(":features:language_lint")
sp...@google.com <sp...@google.com> #11
As opposed to lintPublish
? Or is that not relevant?
sp...@google.com <sp...@google.com> #12
For me this is for local checks so I'm using lintChecks. Removing lintChecks from the library module and only applying it on the app module fixed the lint crash. However that's not optimal as I want to run the lint checks individually on the library module as well. It would not be interesting if this is really the cause of the issue or if it doesn't fix it for others.
sp...@google.com <sp...@google.com> #13
I do not have any custom lint checks declared but there might be a transient lint check pulled in.
au...@google.com <au...@google.com> #14
We have checkDependencies=true
on our app module and apply there custom lint checks. Disabling custom lint checks has not solved the issue, though we have more custom lint checks via external dependencies (for example, timber).
au...@google.com <au...@google.com> #15
#14, could you check with checkDependencies=false
? It fixes problem on my project. Would be nice to hear more proves.
ga...@google.com <ga...@google.com> #16
#15, I've set checkDependencies = false
, but left our custom lint checks enabled. So far lint finished successfully without issue errors.
bi...@google.com <bi...@google.com> #17
In my case, all builds of the >50 were a success after checkDependencies = false
. However, disabling checkDependencies
is not a solution as well. Since all our code is split in small logical modules, there is no point in lint. Too many false-positives and true-negatives.
ga...@google.com <ga...@google.com> #18
I cherry-picked a change to 4.1 Beta 4 which essentially changes this error into a logged warning rather than a hard failure. That does not "fix" the problem, but it at least gets us back to the behavior of 3.6. Can someone confirm that this workaround has worked for them?
Also, I think I know what the root cause is (see notes below). However, it's hard to be sure without a repro scenario. Would anyone be willing to share an open-source project that reproduces this bug? (You can also send the project to
Notes:
-
My current theory is that this bug is related to
.https://issuetracker.google.com/159733104#comment6
I.e., I think Lint should not be reusing the same Kotlin compiler environment to analyze multiple modules, which is what we do whencheckDependencies=true
. -
It is still strange that the failure is nondeterministic. However, one potential reason is that the Kotlin compiler caches many things via
SoftReference
.
je...@google.com <je...@google.com> #19
Sorry for my long delay. I was tried with 4.1.0-beta05
(newest version to date), and the problem is still here. I added new log in case lines were changed.
Would anyone be willing to share an open-source project that reproduces this bug?
I have only closed source project with this problem. Maybe someone knows some quite large multimodule opensource project I could try setup AGP with lint and try reproduction?
je...@google.com <je...@google.com> #20
I tried to reproduce with two small multimodule projects, but all builds works flawlessly. Also, I tried to reproduce using checkDependencies
, and 6 other helper modules. 145k CLOC without tests. I suppose there is a good chance problem happen due to the cache.
It is still strange that the failure is nondeterministic.
It is even non-deterministic in CI/docker builds using the same fresh environment and exactly the same code each time. Build cache and daemon is disabled there. Multithreading should be involved as well.
In addition, I found in most cases failed due to the same file
bi...@google.com <bi...@google.com> #21
je...@google.com <je...@google.com> #22
There are some architectural changes coming in Lint that will fix this properly, but they will not make it into 4.2.
However, there is another workaround you can try that will be available starting in AGP 4.2 Beta 4.
Essentially you can tell Lint to "reset" the Kotlin compiler between each module analysis, thereby clearing all caches. I did not make this the default behavior because the effect on performance is unknown/risky.
To enable this behavior, either set the environment variable LINT_DO_NOT_REUSE_UAST_ENV
to "true", or set the JVM system property lint.do.not.reuse.uast.env
to "true". For example, you can do this from the command line:
./gradlew -Dlint.do.not.reuse.uast.env=true :app:lintDebug
Or by putting this in your gradle.properties
file:
systemProp.lint.do.not.reuse.uast.env=true
je...@google.com <je...@google.com> #23
Status updates:
-
I'm still hoping someone can confirm whether the workaround in
worked for them in AGP 4.2.comment#22 -
Starting with AGP 7.0-alpha13 the root cause of this issue should be fixed completely due to the new "partial analysis" mode (enabled by default) in which Lint analyzes modules independently and merges results along the way. It fixes the issue because Lint will no longer use the same Kotlin compiler environment to analyze multiple modules (and so the risk of stale caches is gone).
je...@google.com <je...@google.com> #24
I'm still hoping someone can confirm whether the workaround in
worked for them in AGP 4.2. comment#22
This unfortunately did not work for us. We actually see lint crashes after enabling via systemProp.lint.do.not.reuse.uast.env=true
. See the attached log. It's also much slower, as expected.
AGP 4.2 seems to make this error much more frequent compared to 4.1, for some reason.
sp...@google.com <sp...@google.com> #25
Can you file a new bug? You can add a comment here linking to it.
je...@google.com <je...@google.com> #26
Sure. Without that workaround, we get the same
ERROR: package fragment is not found for module:<lint-module> is a module[ModuleDescriptorImpl@5e5e6c61] file:KtFile: LiveViewerViewData.kt
error in this ticket occasionally (1-2% of the time?).
je...@google.com <je...@google.com> #27
Oh, I misunderstood. So, using lint.do.not.reuse.uast.env
is what causes the new crash? That is unfortunate, and I will investigate. Let me know if there is a sample project you can share that reproduces the issue.
bi...@google.com <bi...@google.com>
sp...@google.com <sp...@google.com> #28
Not sure if you still wanted the new bug, but here it is:
sp...@google.com <sp...@google.com> #29
FYI the issue in
And to confirm, lint.do.not.reuse.uast.env
should no longer be needed at all in AGP 7.0+.
je...@google.com <je...@google.com> #30
Thanks #29 . I am noticing that when this happens, after the error log for
package fragment is not found for module:<lintWithKotlin> is a module
There is another error
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'descriptor' of org/jetbrains/kotlin/codegen/context/CodegenContext.intoPackagePart must not be null
at org.jetbrains.kotlin.codegen.context.CodegenContext.$$$reportNull$$$0(CodegenContext.java)
at org.jetbrains.kotlin.codegen.context.CodegenContext.intoPackagePart(CodegenContext.java)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject$computeLightClassData$1$1.invoke(LightClassDataProvider.kt:51)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject$computeLightClassData$1$1.invoke(LightClassDataProvider.kt:38)
at org.jetbrains.kotlin.asJava.builder.LightClassBuilderKt.buildLightClass(LightClassBuilder.kt:64)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject$computeLightClassData$1.invoke(LightClassDataProvider.kt:47)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject$computeLightClassData$1.invoke(LightClassDataProvider.kt:38)
at org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport.createDataHolderForClass(CliLightClassGenerationSupport.kt:64)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject.computeLightClassData(LightClassDataProvider.kt:45)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject.compute(LightClassDataProvider.kt:61)
at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:54)
at com.intellij.util.CachedValueBase.lambda$getValueWithLock$1(CachedValueBase.java:235)
at com.intellij.openapi.util.RecursionManager$1.doPreventingRecursion(RecursionManager.java:113)
at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:72)
at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:236)
at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:43)
at
Does the fix address both of these?
sp...@google.com <sp...@google.com> #31
package fragment is not found
and Argument for @NotNull parameter...
), the workaround in 4.2 is to put
systemProp.lint.do.not.reuse.uast.env=true
in your gradle.properties
file as described in
sp...@google.com <sp...@google.com>
sp...@google.com <sp...@google.com> #32
Marking fixed in AGP 7.0.
That is, the lint.do.not.reuse.uast.env
workaround should no longer be needed in AGP 7.0+. And, you should no longer see the following warnings/errors while running Lint:
ERROR: package fragment is not found for module:<lintWithKotlin>...
ERROR: Could not generate LightClass for...
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'descriptor' of org/jetbrains/kotlin/codegen/context/CodegenContext.intoPackagePart must not be null
The issue is fixed due to the new "Lint partial analysis" mode (enabled by default) which creates a standalone UastEnvironment
instance for each module, thereby avoiding stale caches in the Kotlin compiler frontend.
Please comment on the bug if you see any similar errors in AGP 7.0+.
an...@google.com <an...@google.com> #33
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Hedgehog | 2023.1.1 Beta 4
- Android Gradle Plugin 8.2.0-beta04
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
an...@google.com <an...@google.com> #34
The fixes for this issue are now also available in:
- Android Studio Iguana | 2023.2.1 Canary 4
- Android Gradle Plugin 8.3.0-alpha04
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
jf...@block.xyz <jf...@block.xyz> #35
In Gradle 8.3 we are ignoring this file with the following in gradle.properties
:
org.gradle.configuration-cache.inputs.unsafe.ignore.file-system-checks=**/.gradle/.android/analytics.settings
However, the AnalyticsService still breaks configuration on demand for some people:
> Failed to apply plugin 'com.android.internal.library'.
> Accessing GradleBuildProject.Builder through AnalyticsConfiguratorService is not allowed after AnalyticsService is created.
We've found that setting "hasOptedIn":false,"
in ~.gradle/.android/analytics.settings
fixes the issue.
sp...@google.com <sp...@google.com> #36
Re: #35, that looks like
mf...@gmail.com <mf...@gmail.com> #37
وجيهكم خلوني في حالي ..ماهو مقر.طالب
Description
DESCRIBE THE ISSUE IN DETAIL:
STEPS TO REPRODUCE:
./busytown/androidx_device_tests.sh
Expected
Our build is run twice (for up to dateness validation). Second run uses configuration cache
Actual
Second build does not use configuration cache, it is dropped due to