17
Android lint Nikola Kapraljević nixa

Infinum Android Talks #04 - Android Lint

Embed Size (px)

DESCRIPTION

Android lint tool is a static code analysis tool that checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. I'll show few examples and suggestions how we can use it to make application development more enjoyable.

Citation preview

Page 1: Infinum Android Talks #04 - Android Lint

Android lintNikola Kapraljević nixa

Page 2: Infinum Android Talks #04 - Android Lint

Static code analysis tool that checks your Android project source files.

Page 3: Infinum Android Talks #04 - Android Lint

lint• introduced in ADT 16 (and Tools 16)!

• scans Android project sources for potential bugs!

• available as!

• command line tool!

• integrated with Android Studio

Page 4: Infinum Android Talks #04 - Android Lint

Code scanning workflow

Page 5: Infinum Android Talks #04 - Android Lint

$ gradle lint

Page 6: Infinum Android Talks #04 - Android Lint

errors

Page 7: Infinum Android Talks #04 - Android Lint

no errors

Page 8: Infinum Android Talks #04 - Android Lint

android studio doesn’t use lint.xml

Page 9: Infinum Android Talks #04 - Android Lint

command line demo

Page 10: Infinum Android Talks #04 - Android Lint

Android Studio

Page 11: Infinum Android Talks #04 - Android Lint

Android Studio integration

Page 12: Infinum Android Talks #04 - Android Lint

configuring checks

Page 13: Infinum Android Talks #04 - Android Lint

Suppress problems

Page 14: Infinum Android Talks #04 - Android Lint

available checks• $ lint —show!

• lists all available checks!

• http://tools.android.com/tips/lint-checks

Page 15: Infinum Android Talks #04 - Android Lint

my favorites• StringFormatMatches - Ensures that the format used in <string>

definitions is compatible with the String.format call!

• MissingTranslation - Checks for incomplete translations where not all strings are translated!

• ExtraTranslation - Checks for translations that appear to be unused!

• SpUsage - Looks for uses of dp instead of sp dimensions for text sizes!

• UnusedResources - Looks for unused resources!

• HardcodedText - Looks for hardcoded text attributes which should be converted to resource lookup

Page 16: Infinum Android Talks #04 - Android Lint

links• http://tools.android.com/tips/lint!

• http://developer.android.com/tools/help/lint.html

Page 17: Infinum Android Talks #04 - Android Lint

Thank you.