Status Update
Comments
uc...@google.com <uc...@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
je...@google.com <je...@google.com>
ga...@google.com <ga...@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.
ga...@google.com <ga...@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.
ha...@googlemail.com <ha...@googlemail.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?
ha...@googlemail.com <ha...@googlemail.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 :-)
ha...@googlemail.com <ha...@googlemail.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?
je...@google.com <je...@google.com>
ga...@google.com <ga...@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?
ma...@gmail.com <ma...@gmail.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.
ga...@google.com <ga...@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")
ma...@gmail.com <ma...@gmail.com> #11
As opposed to lintPublish
? Or is that not relevant?
ga...@google.com <ga...@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.
ma...@gmail.com <ma...@gmail.com> #13
I do not have any custom lint checks declared but there might be a transient lint check pulled in.
ma...@gmail.com <ma...@gmail.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).
ga...@google.com <ga...@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.
je...@google.com <je...@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
.
ma...@gmail.com <ma...@gmail.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?
ga...@google.com <ga...@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
ma...@gmail.com <ma...@gmail.com> #21
ga...@google.com <ga...@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
ma...@gmail.com <ma...@gmail.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).
ga...@google.com <ga...@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.
ma...@gmail.com <ma...@gmail.com> #25
Can you file a new bug? You can add a comment here linking to it.
ga...@google.com <ga...@google.com>
ma...@gmail.com <ma...@gmail.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?).
ga...@google.com <ga...@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.
jw...@gmail.com <jw...@gmail.com> #28
Not sure if you still wanted the new bug, but here it is:
ga...@google.com <ga...@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+.
dr...@gmail.com <dr...@gmail.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?
jw...@gmail.com <jw...@gmail.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
dr...@gmail.com <dr...@gmail.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+.
ma...@gmail.com <ma...@gmail.com> #33
since the multidex 1.0.2 is live I would expect that multidex works fine on api <21 for test apks, but this is not the case.
Did I misunderstand something when you said this will be backported to legacy multidex so test apk can contain multiple dex files also or?
classpath 'com.android.tools.build:gradle:3.0.0-alpha7'
multidex : '1.0.2',
Android Studio 3.0 Canary 7
Build #AI-171.4182969, built on July 14, 2017
JRE: 1.8.0_152-release-884-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.4
ga...@google.com <ga...@google.com> #34
ma...@gmail.com <ma...@gmail.com> #35
Thank you for the answer but I don't understand what is inside multidex 1.0.2 then.
in support lib Revision 25.4.0 it is stated:
Concurrent with this support library release, we are also releasing multidex version 1.0.2. This version includes the following important changes:
Allows multidexing of instrumentation APK.
Deprecates MultiDexTestRunner (AndroidJUnitRunner should be used instead).
We use multidex 1.0.2. Does this mean this fix will come out in 1.0.3, do you have any eta window on this topic?
Cheers
ga...@google.com <ga...@google.com> #36
ma...@gmail.com <ma...@gmail.com> #37
Looking forward to the integration let us know when you manage to merge it.
Have a nice weekend!
ga...@google.com <ga...@google.com> #38
ma...@gmail.com <ma...@gmail.com> #39
thank you
ga...@google.com <ga...@google.com> #40
ma...@gmail.com <ma...@gmail.com> #41
does this mean this will come out with beta4?
ga...@google.com <ga...@google.com> #42
ja...@gmail.com <ja...@gmail.com> #43
Simply create a "CustomerTestRunner" and override "onCreate" to call "MultiDex.installInstrumentation(context, targetContext)". See this example:
ja...@gmail.com <ja...@gmail.com> #44
yo...@gmail.com <yo...@gmail.com> #45
st...@gmail.com <st...@gmail.com> #47
Can anyone give us an update and an ETA for this ?
We use build tools 26.0.1, gap 3 beta 5, ASTL runner 1.0.1.
st...@gmail.com <st...@gmail.com> #48
ja...@gmail.com <ja...@gmail.com> #49
run new tests.
Jared Burrows
*jaredsburrows@gmail.com <jaredsburrows@gmail.com>*
LinkedIn:
On Thu, Sep 14, 2017 at 12:14 PM, <buganizer-system@google.com> wrote:
dr...@gmail.com <dr...@gmail.com> #50
st...@gmail.com <st...@gmail.com> #51
st...@gmail.com <st...@gmail.com> #52
je...@google.com <je...@google.com> #53
ja...@gmail.com <ja...@gmail.com> #54
[Deleted User] <[Deleted User]> #55
za...@gmail.com <za...@gmail.com> #56
[Deleted User] <[Deleted User]> #57
le...@gmail.com <le...@gmail.com> #58
ga...@google.com <ga...@google.com> #59
ja...@gmail.com <ja...@gmail.com> #60
vy...@pinterest.com <vy...@pinterest.com> #61
cm...@google.com <cm...@google.com>
gl...@fitbit.com <gl...@fitbit.com> #62
cm...@google.com <cm...@google.com> #63
All the changes needed are submitted to the four components (build tools, MultidexTestRunner, AndroidJunitRunner and android gradle plugin) and we'll update this bug as soon as it is released, so it will be in Android Gradle Plugin 3.1.
Note that both the deprecated MultiDexTestRunner and the replacement AndroidJUnitRunner will support legacy multidex test APKs
sz...@gmail.com <sz...@gmail.com> #64
Doing it in 3.1 will require everyone who wants to have multidex for test APK working to start using unstable version of AS and AGP.
zt...@gmail.com <zt...@gmail.com> #65
> `Using multidex to create a test APK is not currently supported.`
cm...@google.com <cm...@google.com>
ga...@google.com <ga...@google.com> #66
ja...@gmail.com <ja...@gmail.com> #67
an...@gmail.com <an...@gmail.com> #68
le...@gmail.com <le...@gmail.com> #69
[Deleted User] <[Deleted User]> #70
[Deleted User] <[Deleted User]> #71
[Deleted User] <[Deleted User]> #72
ga...@google.com <ga...@google.com> #73
You need to use Android plugin for Gradle 3.1.0-alpha04+, any compatible version of Gradle (e.g. 4.4) and BuildTools (e.g. 27.0.3). Multidex library 1.0.2 will be added by the plugin as a dependency automatically. With this, your build will be successful.
To run tests successfully, the test runner needs to support legacy test APK. AndroidJUnitRunner supports that, so you can use that.
ma...@gmail.com <ma...@gmail.com> #74
For example following your suggestion of tl;dr version the test crashes because some files are not found in the main dex file during the app start:
01-09 10:31:06.965 4861-4861/? W/dalvikvm: Class resolved by unexpected DEX: Ltimber/log/Timber$Tree;(0xa75def58):0x99f02000 ref [Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension;] Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension;(0xa75def58):0x99caf000
01-09 10:31:06.965 4861-4861/? W/dalvikvm: (Ltimber/log/Timber$Tree; had used a different Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension; during pre-verification)
01-09 10:31:06.965 4861-4861/? D/AndroidRuntime: Shutting down VM
01-09 10:31:06.965 4861-4861/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa66de228)
01-09 10:31:06.975 4861-4861/? E/InstrumentationResultPrinter: Failed to mark test No Tests as finished after process crash
01-09 10:31:06.975 4861-4861/? E/MonitoringInstr: Exception encountered by: Thread[main,5,main]. Dumping thread state to outputs and pining for the fjords.
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at timber.log.Timber$Tree.getStackTraceString(Timber.java:569)
at timber.log.Timber$Tree.prepareLog(Timber.java:544)
at timber.log.Timber$Tree.i(Timber.java:452)
at timber.log.Timber$1.i(Timber.java:288)
at timber.log.Timber.i(Timber.java:63)
Do you have any idea where does this pops out from?
ga...@google.com <ga...@google.com> #75
This seems to be Java 8 specific bug, and I've filled
st...@gmail.com <st...@gmail.com> #76
fu...@gmail.com <fu...@gmail.com> #77
[Deleted User] <[Deleted User]> #78
[Deleted User] <[Deleted User]> #79
[Deleted User] <[Deleted User]> #80
Until recently we had a big module, with all our code + all our instrurmentation tests code. Then we could check and the plugin (3.1.alpha and 3.1) work well to enable multidex in tests apks.
But we recently dissociated this big module: one contains the production code, the other one contains the instrumentation code. And then, the new plugin breaks: we can still a multidex production app, but the instrumentation test apk is not generated. We hit the 65K limit and the build reports this as an issue. Also, the android test don't have a task: transformClassesWithMultidexlistFor<variant>AndroidTest
What can go wrong ?
[Deleted User] <[Deleted User]> #81
* a few classes in production code
* quite a lot of classes of instrumentation tests
The module_apk wires together all other modules that are all library modules.
When adding multidexEnabled to module_apk, the production apk is multidexed, but not the test apk. There is no transform / task for the AndroidTest variant related to multidex.
When adding multidexEnabled to all default configuration of all modules, all of them have both instrumentation and production multidex tasks & transformations, all except module_apk...
We have no idea what is going wrong.
ga...@google.com <ga...@google.com> #82
I've filled
[Deleted User] <[Deleted User]> #83
Execution failed for task ':app:transformClassesWithMultidexlistForLive'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.
ga...@google.com <ga...@google.com> #84
pe...@layer.com.c-02odbdyf.appstempdomain.goog <pe...@layer.com.c-02odbdyf.appstempdomain.goog> #85
pa...@gmail.com <pa...@gmail.com> #86
ga...@google.com <ga...@google.com> #87
Yes, please file a new bug, and paste the link here. Issue in #78 was due to a custom plugin which would disable multidex. Thanks!
Description
Build #AI-171.3870562, built on April 1, 2017
JRE: 1.8.0_112-release-b736 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
gradle-3.4.1
classpath 'com.android.tools.build:gradle:2.4.0-alpha4'
buildTools : '25.0.1',
compileSdk : 25,
javaVersion: JavaVersion.VERSION_1_8,
minSdk : 16,
targetSdk : 25
Multidex is setup and works fine (compile, assemble and espresso test) with:
classpath 'com.android.tools.build:gradle:2.3.0'
When we bump up to 2.4 alpha 4 we get multidex issue when we try to run the tests:
(I repeat multidex is setup properly and everything works fine on plugin 2.3.0)
This is a scaffold-like very close to our project setup that I created to reproduce various gradle issues we encounter with our enteprise project:
(sadly I did not update it and maintain it in some time I can refresh it if you really need it or feel free to fork or PR)
This is the stacktrace of the issue
This is the command I ran on our project (should be the same on example project I attached)
./gradlew clean connectedNonpayUnitedStatesBleedingDebugAndroidTest --stacktrace
but I repeat I do not know yet does that project compiles even with the new plugin I can update it later on if you need it.