'Ignoring all lint errors and warnings in Android
Is it Ok to ignore lint errors and warnings given by lint if my projects runs perfectly with no errors in my emulator? I'm asking this because I would like tu publish my app to the store (my first android app) and I'm not sure if this will cause any shut downs or any other errors...
Solution 1:[1]
@AnkitSomani's answer says the important things: think about warnings first.
If you want to ignore them, lint can be told to ignore warnings by several methods (document is way longer)
With annotations:
@SuppressLint("NewApi") public void onGlobalLayout() {In .xml files:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> .... <LinearLayout tools:ignore="MergeRootFrame"java comments:
//noinspection AndroidLintSdCardPathxml comments:
<!--suppress AndroidLintHardcodedText -->In Build File: With Gradle Configuration
android { lintOptions { disable 'TypographyFractions','TypographyQuotes' ... } }on the command line
$ lint --disable MissingTranslation,UnusedIds,Usability:Icons /src/astrid/config file 'lint.xml' (next to 'AndroidManifest.xml')
<?xml version="1.0" encoding="UTF-8"?> <lint> <!-- Ignore the ObsoleteLayoutParam issue in the given files --> <issue id="ObsoleteLayoutParam"> <ignore path="res/layout/activation.xml" /> <ignore path="res/layout-xlarge/activation.xml" /> </issue> </lint>Android Studio
To suppress an error, open the issue in the editor and run the quickfix/intentions action (Ctrl/Cmd F1) and select Suppress which will use annotations, attributes or comments to disable the issue.
Solution 2:[2]
There are various levels of Lint errors, as long as they are showing as warnings - the yellow mark - and not errors - the red ones - you are good.
The linter basically just helps you avoid common mistakes - forgetting .show(), or not specifying a default orientation for a LinearLayout.
If the app works, it works. Go for it.
Solution 3:[3]
You can but you definitely should not. Those warnings are here to help you avoid common mistakes which lead to poor code quality. Especially as a beginner, the lint warnings are good to follow.
Some warning can't be avoided sometimes, but at least you should check them and put a specific annotation on it.
Most importantly, understand the warning and be aware of the consequences of not taking care of it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | serv-inc |
| Solution 2 | r2DoesInc |
| Solution 3 | serv-inc |
