If you haven't already, make sure you import the Intrepid Style Template into Android Studio.
TBD
Android Studio supports many static analysis checks to help you write better code and avoid common problems. The primary way we enforce these are via the "lint.xml" file which can be automatically added to every project by including the Static Analysis Gradle Plugin.
This file supports:
- Lint checks in the IDE (the colored lines that show up on the far-right of the editor window)
- Commit-time reporting of warnings/errors (if the "Perform code analysis" box is checked)
- Command-line lint checking (via the "lint" gradle task)
- Automated lint checking via Jenkins
The default lint.xml file we use is located here, within the Static Analysis Gradle Plugin project: lint.xml
-
See the README for the Static Analysis Gradle Plugin project for how to apply this plugin to your project.
-
Run the Gradle task to analyze the code, which will generate the lint.xml file in the correct location in your project:
./gradlew analyze${buildVariant}
(e.g.analyzeDevDebug
) -
Add this lint.xml file to Git and check it in.
That's it! Your project should now be configured to check against the recommended lint inspections. You may modify this lint.xml file if needed to suit your project, but this should only be considered in exceptional circumstances.
Note: If you ever want to update the lint.xml file to the latest version, do the following:
- Upgrade to the newest version of the
static-analysis-gradle-plugin
- Delete the
lint.xml
file (so when the static analysis command is run in step #3 it will re-generate a new lint.xml file) - Re-run the
./gradlew analyze${buildVariant}
command
This will re-generate the lint.xml file with the latest changes.
Lint supports the following levels for each inspection:
- ignore (do not report)
- informational (will show in a lighter color, and will not show up at commit-time)
- warning (highlight in yellow - will block commits)
- error (red - will block commits)
- fatal (will cause the gradle build to fail if the
lintAbortOnError
option was set totrue
in thestaticAnalysis
block in your build.gradle file - will block commits)