2

When I run lint in Android Studio via Analyze -> Inspect Code I am able to select from a large variety of things to look for.

When I go to the command-line version of lint and list all available things to check (lint --list), I get a list that does not include all the inspections I see in Android Studio.

For example, I am able to run an inspection with ID ConstantConditions in Android Studio, but am unable to run it on the command-line.

Android Studio

~/app [master] lint --check ConstantConditions --xml results.xml app
  Invalid id or category "ConstantConditions".

Is Android Studio using some other version of lint? Here is some info on the command-line version of lint:

~/app [master] which lint
  lint is /Users/Mark/android-sdk-macosx/tools/lint
~/app [master] lint --version
  lint: version 24.3.3
Mark
  • 7,306
  • 8
  • 45
  • 87

1 Answers1

2

IntelliJ IDEA has a concept of "inspections", and Android Studio inherits this. For any given problem reported by Android Studio's inspection engine, there can be three theoretical sources:

  1. A stock IDEA inspection, one that Android Studio simply adopted.

  2. An Android Studio-specific inspection, for something that perhaps can only readily be detected from within the IDE versus from external Lint tools.

  3. Something from Lint.

I have no idea if #2 is actually used by anything, but it's well within the realm of possibility.

In terms of your error, either that's something that is not Lint (e.g., an IDEA inspection) or there is a naming difference between how the inspection is represented and the command-line equivalent. Since this stuff isn't especially well-documented, it's difficult to say what's going on.

However, in general, do not assume that everything that you see Android Studio yelping about is necessarily something from Lint.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thank you for the quick and thorough response, @CommonsWare. You are a true hero in the Android development community! – Mark Jul 28 '15 at 23:42
  • @Mark: Thanks for the kind (if completely over the top) words! :-) – CommonsWare Jul 29 '15 at 00:06
  • 1
    Hey @CommonsWare - check this out: https://code.google.com/p/android/issues/detail?id=181677. I haven't tried it yet, but it seems like it's doable if you can suffer through lots of XML files. :) Want to update your answer to include this potential avenue of attack? – Mark Jul 30 '15 at 20:40
  • @Mark: You're certainly welcome to experiment with it, and if you get it working to your satisfaction, post your own answer and switch your accept checkmark to it. What Tor describes sounds like it's "not ready for prime time" for most developers, though it may fit your needs with some additional tooling work on your part to deal with the veritable cornucopia of angle-brackety output. – CommonsWare Jul 30 '15 at 20:46