| Start |
|---|
| Using tools:ignore in xml files The attribute BUT dismissing lint warnings with this technique is most of the time the wrong way to proceed. A lint warning must be understood and fixed... it can be ignored if and only if you have a full understanding of it's meaning and a strong reason to ignore it. Here is a use case where it legitimate to ignore a lint warning:
Then you can do this in your manifest : (i.e. requesting the protected permission and ignoring the lint warning because you know that in your case the permission will be granted) |
| Configure LintOptions with gradle You can configure lint by adding a You can run lint for a specific variant (see below), e.g. Check here for the DSL reference for all available options (opens new window). |
| Configuring lint checking in Java and XML source files You can disable Lint checking from your Java and XML source files. Configuring lint checking in JavaTo disable Lint checking specifically for a Java class or method in your Android project, add the Example: To disable checking for all Lint issues: Configuring lint checking in XMLYou can use the For example: To suppress checking for all Lint issues in the XML element, use |
| Importing resources without "Deprecated" error Using the Android API 23 or higher, very often such situation can be seen: This situation is caused by the structural change of the Android API regarding getting the resources. Now the function: should be used. But the android.support.v4 library has another solution. Add the following dependency to the build.gradle file: Then all methods from support library are available: Moreover more methods from support library can be used: |
| How to configure the lint.xml file You can specify your Lint checking preferences in the Example: By setting the severity attribute value in the tag, you can disable Lint checking for an issue or change the severity level for an issue. The following example shows the contents of a |
| Mark Suppress Warnings It's good practice to mark some warnings in your code. For example, some deprecated methods is need for your testing, or old support version. But Lint checking will mark that code with warnings. For avoiding this problem, you need use annotation @SuppressWarnings. For example, add ignoring to warnings to deprecated methods. You need to put warnings description in annotation also: Using this annotation you can ignore all warnings, including Lint, Android, and other. Using Suppress Warnings, helps to understand code correctly! RemarksThe Lint tool checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. You can run Lint from the command-line or from Android Studio. Official documentation:https://developer.android.com/studio/write/lint.html (opens new window) |
Read Article
https://develop.horje.com/learn/1434/reference