SpotBugs is a static analysis tool that looks for potential bugs in Java code. It does not support Kotlin. It can be used in both pure Java, and Android Java projects. It then only makes sense to have SpotBugs enabled if you have Java code in your project. The plugin only runs SpotBugs on projects that contain the Java or the Android plugin.
Enabling and configuring SpotBugs for a project is done through the spotbugs
closure:
spotbugs {
toolVersion // Optional string, the latest SpotBugs release (currently 4.0.0-beta4)
excludeFilter // A file containing the SpotBugs exclusions, e.g., teamPropsFile('static-analysis/spotbugs-excludes.xml')
htmlReportEnabled true // Control whether html report generation should be enabled. `true` by default.
includeVariants { variant -> ... } // A closure to determine which variants (only for Android) to include
}
For more information about SpotBugs rules, refer to the official website.
If your project mixes Java and Kotlin code, you will need to exclude your Kotlin files by using excludeFilter