New issue
Advanced search Search tips

Issue 597007 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 583098



Sign in to add a comment

Android lint sometimes has false-negatives when incremental compiling

Project Member Reported by agrieve@chromium.org, Mar 22 2016

Issue description

To reproduce (from lambroslambrou@):

I've uploaded a CL here: https://codereview.chromium.org/1815803002/

This "UnusedResources" bug is quite flaky, but these steps seem to repro the problem consistently with a minimal app:

Patch the CL into your checkout.
Configure a new out/foo directory with 'gn args' and set target_os = "android" (just that, no other args).
Build the remoting_host_apk target.
Now edit the remoting/android/BUILD.gn and uncomment the line which adds AnotherClass.java.
Build the remoting_host_apk target again.

When I do this, I get the following output:

ninja: Entering directory `out/bare-bones-host-apk'
[1/1] Regenerating ninja files
[18/34] ACTION //remoting/android:remoting_host_apk__java__lint(//build/toolchain/android:arm)

res/layout/main.xml The resource `R.layout.main` appears to be unused: UnusedResources [warning]

Lint found 1 new issues.
 - For full explanation refer to out/bare-bones-host-apk/gen/remoting/android/remoting_host_apk__java__lint/result.xml
 - Wanna suppress these issues?
    1. Read comment in build/android/lint/suppressions.xml
    2. Run "python build/android/lint/suppress.py out/bare-bones-host-apk/gen/remoting/android/remoting_host_apk__java__lint/result.xml"

[33/33] STAMP obj/remoting/android/remoting_host_apk.stamp
 
Cc: lambroslambrou@chromium.org jbudorick@chromium.org
Looked into this and have found a few gems:

One reason it may appears flakey: If you re-run manually without setting FORCE_REBUILD=1, then the command isn't actually run (due to it detecting its inputs to have not been changed)

In this case though, the problem is with an optimization I recently added:
https://codereview.chromium.org/1733893003

This attempted to only lint .java files that have changed, and was meant to be applied only when no resource directory is specified.

There's an edge case that's being hit here:
If you have an AndroidManiest.xml, we pass to lint it's parent directory. lint then detects a res/ as a sibling, and slurps in the resources even though no --resources were passed!

It looks like this implicit passing of src/ and res/ is an unintended consequence of the GN usage of lint, but may be relied upon by GYP.

The fix (I think) is to put the AndroidManifest.xml in the temp directory along with the sources when --java-files is present, and to just disable the optimization when --src-dirs is present (GYP).
Blocking: 583098
Status: Fixed (was: Started)

Sign in to add a comment