27

When I run the following on a command line:

./gradlew -lint

I get different results than if I choose the following menu option within Android Studio.

Analyze->Inspect Code...

Can anyone explain this? Is this normal? Should a prudent developer run both in order to find all potential problems with his/her project?

gonzobrains
  • 7,856
  • 14
  • 81
  • 132
  • Which types of lint warnings/errors does one get that the other doesn't? Studio has some of its own lint checks (such as spelling checks), but they don't always translate directly to signs of poor code quality. – Bryan Herbst Jul 22 '14 at 20:59

3 Answers3

29

You are running two different tools. The command:

$ ./gradlew lint

runs the lint tool that comes with the Android SDK and the menu option

Analyze->Inspect Code...

in Android Studio is a feature inherited from JetBrains IntelliJ IDEA which runs:

<android studio path>/bin/inspect.sh
Robert
  • 434
  • 1
  • 4
  • 8
11

In Android Studio you can customize what inspections are run via Preferences > Inspections; you may have some Lint inspections disabled, and not all run by default. Android Studio can also run a great number of non-Lint inspections.

Scott Barta
  • 79,344
  • 24
  • 180
  • 163
  • Yes, but how does that affect lint inspections run when gradlew is invoked on the command line? – gonzobrains Jul 24 '14 at 19:16
  • It doesn't affect what's run from the command line, but it may explain the differences between those two environments -- when you run from Android Studio, some inspections may be turned off, and there will be a number of IDE-specific inspections that the command line doesn't see – Scott Barta Jul 24 '14 at 19:47
2

If your project includes build variants, and you instead want to run the lint task for only a specific build variant, you must capitalize the variant name and prefix it with lint.

gradlew lintDebug

To learn more about running Gradle tasks from the command line, [read Build Your App from the Command Line.][1]

https://developer.android.com/studio/build/building-cmdline

Pallav Khare
  • 471
  • 1
  • 7
  • 12