简体   繁体   English

通过 Android Studio 菜单和 gradlew 命令行运行 lint 的区别

[英]Difference between running lint via Android Studio menu and gradlew command-line

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.我得到的结果与在 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?谨慎的开发人员是否应该同时运行两者以发现他/她的项目的所有潜在问题?

You are running two different tools.您正在运行两种不同的工具。 The command:命令:

$ ./gradlew lint

runs the lint tool that comes with the Android SDK and the menu option运行 Android SDK 自带的 lint 工具和菜单选项

Analyze->Inspect Code...

in Android Studio is a feature inherited from JetBrains IntelliJ IDEA which runs:在 Android Studio 中是从 JetBrains IntelliJ IDEA 继承的一个功能,它运行:

<android studio path>/bin/inspect.sh

In Android Studio you can customize what inspections are run via Preferences > Inspections;在 Android Studio 中,您可以通过 Preferences > Inspections 自定义运行哪些检查; you may have some Lint inspections disabled, and not all run by default.您可能禁用了一些 Lint 检查,并非所有检查都默认运行。 Android Studio can also run a great number of non-Lint inspections. Android Studio 还可以运行大量非 Lint 检查。

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.如果您的项目包含构建变体,而您只想为特定构建变体运行 lint 任务,则必须将变体名称大写并使用 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 https://developer.android.com/studio/build/building-cmdline

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM