Tagandroid

Android Lint: Ignore specific errors

The 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.

Running

Running lint in command line

Running lint in Android Studio

To run lint in Android Studio go to Analyze > Inspect Code

Configuring

Lint has a lot of option you can use in your build.gradle

See the complete options list in Gradle Plugin User Guide

To see the complete list of issues and categories id’s use:

Ignoring Erros

Lint is part of Gradle build process, by default if it fail your build will stop and you will get a message like it:

In 99% of the cases people will start ignore lint instead of fix the problems, adding this on build.gradle app

But IMHO it’s wrong. If lint is telling, you have a problem the best thing to do is fix it. Lint is a tools to make your app and the UX better.

Ignoring specific erros

Sometimes you really need to ignore some lint errors. For example, when you are using webView.getSettings().setJavaScriptEnabled(true); in your WebView

In this case, you should disable only the specific ids instead of disabling the whole lint.

You also can ignore it directly in your code:

Or in your XML

If you prefer you can move all your issues rules from a lint.xml file in the root directory of your project.

Android Virtual Device: tips and tricks

One of the Android Developer’s best friends is the emulator (aka AVD). It allows us to simulate some behaviors, like calling, sending SMS messages, simulate a specific location and much more.

Creating an emulator

Creating an Android Virtual Device is very simple, just make sure you have the system image of the Android version you need to simulate installed.

Android SDK Manager - System Image
Android SDK Manager – System Image

 

You can see a list of available options on the Android website: https://developer.android.com/tools/devices/managing-avds-cmdline.html

Emulator keyboard mapping

In general I use keyboard mappings for everything. I think it makes me more productive. AVD has some nice keyboard mappings to simulate the real experience closer to a real device.

MappingDescription

ESC Back
F4 Hangup/end call button
F7 Power button
F8 Toggle cell networking on/off
Ctrl + F5 Audio volume up button
Ctrl + F6 Audio volume down button
Ctrl + F11 Change layout orientation

See the complete list on Android website: http://developer.android.com/tools/help/emulator.html

Logcat

One of the most important tools for the Android developer is logcat. Logcat is a simple way to see the system logs and debugging output from device/emulator. You can use logcat from an ADB shell to view the log messages.

Tips and tricks

The following commands need to be run using telnet

Android Emulator
Android Emulator

Receiving a call

Receiving a SMS

Power battery

Network speed

To see the list of available options type help inside telnet’s prompt.

Categories

Tags