Reputation: 13733
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...
Upvotes: 3
Views: 11804
Reputation: 1192
If you understand the warning well enough, and are sure that it is not going to affect the App's behavior (maybe in other devices), you can go for it.
For example even if you know, tell other-developers by comments, maybe in root build.gradle
file, like:
android {
lintOptions {
// TODO: remove below once we have time to update entire logic.
disable 'some_warning_id'
}
}
But, If you are not sure then certainly you should fix all the lint warnings. Lint error/warnings are very basic for android apps.
Upvotes: 4
Reputation: 14948
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.
Upvotes: 1
Reputation: 38307
@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 AndroidLintSdCardPath
xml 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.
Upvotes: 4
Reputation: 3771
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.
Upvotes: 1