5.5 Lint支持

从0.7.0版本之后,你可以为一个特定的变种版本运行 lint ,也可以为所有变种版本都运行.在这种情况下,它会产生一个报告指出给定的变种版本的问题.

你可以像下面一样通过 lintOptions 自定义 lint .一般情况下,你只需要配置其中的一部分.以下是展示所有可用的 lint 配置项.

  1. android {
  2. lintOptions {
  3. // set to true to turn off analysis progress reporting by lint
  4. quiet true
  5. // if true, stop the gradle build if errors are found
  6. abortOnError false
  7. // if true, only report errors
  8. ignoreWarnings true
  9. // if true, emit full/absolute paths to files with errors (true by default)
  10. //absolutePaths true
  11. // if true, check all issues, including those that are off by default
  12. checkAllWarnings true
  13. // if true, treat all warnings as errors
  14. warningsAsErrors true
  15. // turn off checking the given issue id's
  16. disable 'TypographyFractions','TypographyQuotes'
  17. // turn on the given issue id's
  18. enable 'RtlHardcoded','RtlCompat', 'RtlEnabled'
  19. // check *only* the given issue id's
  20. check 'NewApi', 'InlinedApi'
  21. // if true, don't include source code lines in the error output
  22. noLines true
  23. // if true, show all locations for an error, do not truncate lists, etc.
  24. showAll true
  25. // Fallback lint configuration (default severities, etc.)
  26. lintConfig file("default-lint.xml")
  27. // if true, generate a text report of issues (false by default)
  28. textReport true
  29. // location to write the output; can be a file or 'stdout'
  30. textOutput 'stdout'
  31. // if true, generate an XML report for use by for example Jenkins
  32. xmlReport false
  33. // file to write report to (if not specified, defaults to lint-results.xml)
  34. xmlOutput file("lint-report.xml")
  35. // if true, generate an HTML report (with issue explanations, sourcecode, etc)
  36. htmlReport true
  37. // optional path to report (default will be lint-results.html in the builddir)
  38. htmlOutput file("lint-report.html")
  39. // set to true to have all release builds run lint on issues with severity=fatal
  40. // and abort the build (controlled by abortOnError above) if fatal issues are found
  41. checkReleaseBuilds true
  42. // Set the severity of the given issues to fatal (which means they will be
  43. // checked during release builds (even if the lint target is not included)
  44. fatal 'NewApi', 'InlineApi'
  45. // Set the severity of the given issues to error
  46. error 'Wakelock', 'TextViewEdits'
  47. // Set the severity of the given issues to warning
  48. warning 'ResourceAsColor'
  49. // Set the severity of the given issues to ignore (same as disabling the check)
  50. ignore 'TypographyQuotes'
  51. }
  52. }