Status Update
Comments
xa...@google.com <xa...@google.com> #2
gh...@google.com <gh...@google.com> #3
Thanks!
Other notes: I think this is technically a regression, because Lint checks are prepared during generateDebugSources
and that used to run during Gradle sync(?)
co...@protonmail.com <co...@protonmail.com> #4
1. I typically was using "make project" because that's what the lint video from ADS shows.
2. In the sample project, If I Right click activity main.xml > analyze > inspect code > Inspection Scope [FILE]
"No lint errors found." This is also weird. You would think that maybe forcefully inspecting the code would create the lint.jar file?
3. In my sample project, running ./gradlew lintDebug makes lint checks work in the IDE again. Amazing! Here is the output for example:
```
coltonidle:CustomLintChecksDoNotWork cidle$ ./gradlew lintDebug
> Task :app:lintDebug FAILED
Wrote HTML report to file:///Users/coltonidle/project/CustomLintChecksDoNotWork/app/build/reports/lint-results-debug.html
Wrote XML report to file:///Users/coltonidle/project/CustomLintChecksDoNotWork/app/build/reports/lint-results-debug.xml
FAILURE: Build failed with an exception.
```
Okay. That makes sense. Failed because of my custom lint error. Now let me try my production project that is a pretty big project, but it's not ridiculously complex. Pretty standard. I do have a few extra modules for a few custom views.
```
> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Task :customView1:lintDebug
Wrote HTML report to file:///Users/coltonidle/project/myapp/customView1/build/reports/lint-results-debug.html
Wrote XML report to file:///Users/coltonidle/project/myapp/customView1/build/reports/lint-results-debug.xml
> Task :customView2:lintDebug
Wrote HTML report to file:///Users/coltonidle/project/myapp/customView2/build/reports/lint-results-debug.html
Wrote XML report to file:///Users/coltonidle/project/myapp/customView2/build/reports/lint-results-debug.xml
> Task :customView3:lintDebug
Wrote HTML report to file:///Users/coltonidle/project/myapp/customView3/build/reports/lint-results-debug.html
Wrote XML report to file:///Users/coltonidle/project/myapp/customView3/build/reports/lint-results-debug.xml
BUILD SUCCESSFUL in 22s
```
Hmmm. That's weird. Successful and not failed (like the sample) and also... where is my :app module outputs?
I see that in all my modules I have
lintOptions {
abortOnError false
}
but in my app module I have
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
so I thought maybe checkReleaseBuilds false, was the cause of some lint issue. But no. When I removed it, it still didn't show. So now I have another problem seemingly where lintDebug won't process my app module
4. Running ./gradlew assemble fails for me because it tries to run a release with signing configs I don't have available. Maybe this is the cause of why lint checks don't work via ./gradlew lintDebug?
Will keep investigating!
co...@protonmail.com <co...@protonmail.com> #5
This most definitely wasn't happening in the past. All of a sudden (couldn't pinpoint which AS of AGP version) it just stopped reporting custom lint checks in the IDE for my entire teams usual workflow. e.g. Write some code and deploy.
Once we noticed that they weren't properly showing then we started to try to force lint to rebuild or remake, but never got it to work. This also reminds me that a few weeks ago we also had an issue where we were making a change to module called customView1 and the changes weren't reflecting. We tried hitting the hammer icon and general clean and stuff, but nothing triggered it. Not sure how we got that module to rebuild, but maybe those things are somehow related as well?
co...@protonmail.com <co...@protonmail.com> #6
I found my issue. It was this that was in the ./gradlew assemble logs. This issue was something I added by accident yesterday when copying and pasting files into my sample project
Task :app:lintVitalStandardProdRelease
Could not load custom lint check jar file /Users/coltonidle/project/myapp/app/build/intermediates/lint_jar/global/lint.jar
I fixed the typo in my class name that I introduced yesterday and that fixed the issue (the original issue still exists, it's just that this issue I introduced yesterday was causing point 3 and 4 to happen from the above comment)
But now I have another issue
gh....
./gradlew assemble my lint.jar gets generated successfully because I can see my lint error after a clean. But when I run ./gradlew lintDebug on my prod app I get
```
> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Task :customView1:lintDebug
Wrote HTML report to file:///Users/coltonidle/project/myapp/customView1/build/reports/lint-results-debug.html
Wrote XML report to file:///Users/coltonidle/project/myapp/customView1/build/reports/lint-results-debug.xml
> Task :customView2:lintDebug
Wrote HTML report to file:///Users/coltonidle/project/myapp/customView2/build/reports/lint-results-debug.html
Wrote XML report to file:///Users/coltonidle/project/myapp/customView2/build/reports/lint-results-debug.xml
> Task :customView3:lintDebug
Wrote HTML report to file:///Users/coltonidle/project/myapp/customView3/build/reports/lint-results-debug.html
Wrote XML report to file:///Users/coltonidle/project/myapp/customView3/build/reports/lint-results-debug.xml
BUILD SUCCESSFUL in 22s
app results are still no where to be found.
co...@protonmail.com <co...@protonmail.com> #7
Looks like the issue is back? I can't seem to get my lint errors to appear. I gave up for a while on my custom lint checks after verifying that ./gradlew asemble was indeed generating the lint jar, but now in AS 4.0 Beta 3, if I run assemble I don't see any of my checks.
=(
co...@protonmail.com <co...@protonmail.com> #8
agp 4.1.0-alpha04
lint 27.1.0-alpha04
I did a clean. All of my custom lint checks in my xml layout went away, as expected
Scenarios I tried to bring my checks back:
1. hit the build button (hammer) and none of my lint checks are there, this is what I really want fixed
2. hit cmd shift a, "make project" and none of my lint checks are there, this is what I really want fixed
( I typically was using "make project" because that's what the lint video from ADS shows.
3. ./gradlew assembleDebug still no lint checks, , this is what I really want fixed
4. ./gradlew :app-lint:assemble still no lint checks, , this sounds like it should be fixed
5. ./gradlew lintDebug lint checks aren't even generated for my app module. Refer to #6. This is still happening, but could be a different issue
6. Ran clean again, then ./gradlew assemble, lint checks are still not there.
Please help! I can't generate my lint jar, making all of my custom lint checks worthless!
ce...@gmail.com <ce...@gmail.com> #9
Lint is not able to recognize any rules around third-party custom lint checks. It fails with the message: "Error: Unknown issue id ..."
In our specific scenario, we rely on MParticle, and given that our app has a bunch of modules, lint complains about this specific rule (
co...@protonmail.com <co...@protonmail.com> #10
As per the ticket that was opened I'm trying
- `./gradlew assemble`
- `./gradlew lintDebug`
(which is already problematic because the build/run button in AS used to init your lint checks in the IDE.)
./gradlew assemble doesn't work for me
./gradlew lintDebug doesn't work for me, BUT I have a build variant and if I call lintPaidDebug then the lint checks do show up in the IDE.
Just to clarify. Please fix the regression of the build/run button in the IDE not generating/showing custom lint checks in the IDE. This has been broken for months and makes my lint checks useless since my team doesn't have CI in place we adhere to lint checks in the IDE.
co...@protonmail.com <co...@protonmail.com> #11
In the latest canary + AGP (8)
It seems like the workaround is now even completely broken. Running ./gradlew lintPaidDebug in AS 4.1 Canary 7 + agp 4.1.0-alpha07 + lint 27.1.0-alpha07 works, but moving to AS 4.1 Canary 8 + agp 4.1.0-alpha08 + lint 27.1.0-alpha08 makes it not work, and then if I rollback to AS 4.1 Canary 7 + agp 4.1.0-alpha07 + lint 27.1.0-alpha07 then everything works again.
gh...@google.com <gh...@google.com> #12
za...@gmail.com <za...@gmail.com> #13
which is not accessible. Could it be made public?
On Mon, May 4, 2020 at 9:32 PM <buganizer-system@google.com> wrote:
xa...@google.com <xa...@google.com> #14
In 4.1, "Make Project" should now again make the lint checks and make them available to Lint. This is because we stop "preparing" them (which is fancy word for moving them somewhere to be consumed).
However, deploying the app will not build the lint checks. We want this action to be exclusively focused on deploying the app and we don't want to do extra build actions.
Right now you can manually trigger building the lint checks via the Build
> Run Generate Source Gradle tasks
menu action. This is not a great place for it but it's a good temp work around.
In 4.2 we will create a custom action to rebuild just the lint checks. I have created
tn...@google.com <tn...@google.com> #15
(Note that you can assign a keyboard shortcut to that action.)
co...@protonmail.com <co...@protonmail.com> #16
tn...@google.com <tn...@google.com> #17
Xav's fixes will be included in 4.1 Canary 11 (canary 9 is still the current version; we're testing canary 10 at the moment but these fixes went in after the cutoff for that build).
co...@protonmail.com <co...@protonmail.com> #18
In general though, as long as my teams custom lint checks "just work" in a normal workflow (clone source from git, clean + run) then we should be all good. Maybe I'm missing something, but it sounds like there will probably still be some extra step that my team unfortunately has to remember to do. I wish I could have my lint checks just be as high of a priority as the default lint checks. Or else, what's the point of writing custom lint checks if the developer can't catch the issues while writing the code (like the default android lint checks)
xa...@google.com <xa...@google.com> #19
Yes there will be some extra steps.
We could do a post sync/project open action to build theses in the background, but it's going to be hard to fully automate this I think. It would be nice to just rebuild them as they change, but I think we really don't want to make building them part of the deploy build.
Maybe a notification bubble that lint checks seems to be out of sync and a nudge to rebuild them? Tor, what do you think?
co...@protonmail.com <co...@protonmail.com> #20
Please let me know if you think our flow of using custom lint checks is wrong, we're a small team (6 people) and so this makes sense for us. I've started my own personal projects and added a custom-lint module as well and it's just crazy to me how it doesn't work. Maybe a gentle reminder in the IDE would really be best? It would at least also solve the issue of what happens when you update the lint check and you don't know how to rebuild and reapply to your project. In order for our team to keep creating lint checks and keep adhering to lint checks, we just want to jump through as little hoops as possible and without shooting ourselves in the foot. Currently we're doing both of those things (jumping through hoops + shooting ourselves in the foot). Right now it feels like someone really has to be an expert on lint to know how to build the checks and then apply them.
We will try again on Canary 11, but I would really appreciate any gentle nudge you can give developers to make sure they are actually applying their custom lint checks.
di...@gmail.com <di...@gmail.com> #21
IMO, readying Lint checks seems sensible to do upon sync. It should be fast since building those modules will often be up-to-date, and syncing is already what many people consider to be the "make my IDE understand the project" button, the IDE's behavior is directly affected by lint checks.
xa...@google.com <xa...@google.com> #22
How do you actually run Lint? I'm guessing you don't rely on lint highlights in the editor.
We should definitively hook into the Analyze
> Inspect Code...
action (And others like Run Inspection by Name...
) and force a build before running this. I've filed
xa...@google.com <xa...@google.com> #23
co...@protonmail.com <co...@protonmail.com> #24
That's exactly what we're looking for. Lint highlights while working on our project. Just how default lint checks short circuit you from doing something bad, we rely on our custom lint checks to also prevent us from using the wrong style, importing the wrong class, etc. We want these to be alerted to the developer while developing (just like default lint). At the moment every developer has to remember to run ./gradlew lintPaidDebug after they clean their project, and then they will get custom lint checks working.
xa...@google.com <xa...@google.com> #25
ok, so my comment about also building before running full code analysis is not helpful.
I just realized that we also run source generation about a clean (Build
> Clean Project
) so we should add building lint checks as part of that action as well. I'm amended
We will discuss how we can nudge users to rebuild lint checks when something happens. The IDE keeps track of file states, so as long as we can internal flag these projects as producer of lint checks (because there are referenced by another project via lintChecks
) this should be doable.
co...@protonmail.com <co...@protonmail.com> #26
1. Watch Dev Summit video on adding custom lint checks
2. Add custom lint checks to repo
3. Your entire team now sees all custom lint checks in the IDE
4. Celebrate because you're now making less mistakes!
tn...@google.com <tn...@google.com> #27
The reason timber works is that lint checks that are associated with AARs should always be picked up no matter what -- they don't require any "building" from AGP's perspective. They're just there next to the other library resources -- classes.jar, res, lint.jar, etc. Locally bundled rules (as source code) are different, and require work to get built and wired in.
Xav, do I understand correctly that the problem here is with projects that use the "lintChecks" and/or "lintPublish" configurations? And if that's the case, we see those as part of the sync results, right? If so, I think it should be straightforward to trigger a generate sources build right there as part of sync. Yes, that will make sync slower, but I don't think anyone who has a setup which includes locally built lint rules would NOT want those built at least once.
Also, is there some easy workaround for Colton here? Could he just make the assembleDebug task depend on this generate task (what is the task name?). If so, then pressing Ctrl/Cmd - F9 in the IDE would not just build the the code for the app but also the lint rules. Once we have Gradle instant execution on there would be almost zero overhead for this, right?
xa...@google.com <xa...@google.com> #28
Yes the problem is only for sub-projects that contribute lint checks. As you mention, AAR-provided lint checks are not impacted.
Right now the model does not contain the projects that contribute lint checks, only their jar output location, so we need to change this (
I've filed
In the mean time, yes you can manually make the task depend on it. In 4.1 (canary 11) we've introduced a new task called compileLintChecks
, so you can make your assembleDebug
depend on it. This is not great as it'll slow down your deploy build but it's a good workaround for now.
co...@protonmail.com <co...@protonmail.com> #29
"but I don't think anyone who has a setup which includes locally built lint rules would NOT want those built at least once." -Tor
Bingo ^ They are a dependency of my build and I would expect them to be built if they are out of date.
ku...@gmail.com <ku...@gmail.com> #30
My app includes lint checks that come from an external jar dependency and we also hit this issue. The lint checks are not created in a subproject and not do not come from an AAR.
E.g. lintChecks 'com.custom.lint:checks:1.0.0
We should also make sure these are always picked up by the IDE. I don't think
xa...@google.com <xa...@google.com> #31
This should work in canary 11. Please do check and let me know if it does not work.
he...@ataulm.com <he...@ataulm.com> #32
xa...@google.com <xa...@google.com> #33
Making a dependency on prepareLintJar
would work. but this task disappeared in 4.1 so it'll fail to build/sync once you update.
co...@protonmail.com <co...@protonmail.com> #34
tn...@google.com <tn...@google.com> #35
Xav said it should be fixed in 4.1 canary 11 so that means it should be in 4.1 beta as well; is it not working for you?
co...@protonmail.com <co...@protonmail.com> #36
Two more questions
1. Is there still hope for custom lint checks to be shown once you press "run"?
2. In the meantime, is there a task that I can append onto my clean task so that after a clean, our custom lint checks show in the IDE? Our custom lint checks are super important to us (we have over 40 at this point) and we're really trying to enable the team to see them without having to remember to do anything after a clean (which we do consistently throughout the day.
xa...@google.com <xa...@google.com> #37
We are looking at better ways to integrate lint checks into the flow.
There are currently two issues that track various works
- New Build action to build lint checks sub-projectsIssue 157134768 - Monitor changes to Custom lint check source code and nudge user to rebuild themIssue 157148185
Building them automatically during a deployment is something we can look into. We are a bit wary of doing any extra work during deployment since we want this to be as fast as possible but it's possible we will enable this anyway (especially once we have file watching). I've filed
tn...@google.com <tn...@google.com> #38
Can you say more about (2) -- why do you clean consistently throughout the day? Clean deletes all the built artifacts. That would include any locally built lint rules too, right?
co...@protonmail.com <co...@protonmail.com> #39
li...@gmail.com <li...@gmail.com> #40
In my multimodule project I tried both options:
- :app (lintCheck(":checks"))
- :app (implementation(":checks-publisher); :checks-publisher (lintPublish(":checks")
Another words I tried to add checks directly to the app and through the library module. Both options lead to my check fire during the ./gradlew :app:lint task execution. However neither of the implementations made the highlighting in Android Studio work.
My Android Studio version is 4.1.3, Gradle 6.8.2, AGP 4.0.1, Lint 27.0.1.
However, if I apply the same versions to this project -
Description
Specifically, pressing "Make Project" will build the custom Lint check modules, but it will not "prepare" those Lint checks for use in the IDE. That is, it does not create a
lint.jar
file in the intermediate build outputs directory. Some users are running into this and thinking that there's something wrong with their custom Lint checks.Seehttps://github.com/ColtonIdle/CustomLintChecksDoNotWork for a good sample project to play around with on Studio 3.6. Notice that
app/build.gradle
declares alintChecks
dependency on the:custom_lint_checks
module. You can check whether the custom Lint checks are working by openingactivity_main.xml
and looking for a Lint error on theButton
tag. Be sure to run./gradlew clean
before running "Make Project".For reference, here are some things that cause the checks to work in the IDE after a clean:
./gradlew assemble
./gradlew lintDebug
And here are some things that don't cause the checks to work again:
./gradlew assembleDebug
(seems surprising)./gradlew :custom_lint_checks:assemble
(could be surprising to some users)This bug might be related to b/66166521 ("Add lintChecks dependencies into the builder model").