Difference between running lint via Android Studio menu and gradlew command-line
Asked Answered
C

3

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?

Catena answered 22/7, 2014 at 20:56 Comment(1)
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.Voluntary
H
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.

Hutcherson answered 22/7, 2014 at 20:58 Comment(2)
Yes, but how does that affect lint inspections run when gradlew is invoked on the command line?Catena
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 seeHutcherson
P
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
Priestley answered 11/11, 2015 at 7:42 Comment(1)
Yes, I see they are different tools, but what are the differences after running them?Delmerdelmor
H
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.

Hutcherson answered 22/7, 2014 at 20:58 Comment(2)
Yes, but how does that affect lint inspections run when gradlew is invoked on the command line?Catena
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 seeHutcherson
P
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

Pirbhai answered 30/8, 2020 at 9:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.