Questions tagged [android-lint]

Android Lint is a tool in ADT which scans Android project sources for potential bugs.

Android Lint is a tool in which scans project sources for potential bugs. It is available both as a command line tool, as well as integrated with .

Here are some examples of the types of errors that it looks for:

  • Missing translations (and unused translations)
  • Layout performance problems (all the issues the old layoutopt tool used to find, and more)
  • Unused resources
  • Inconsistent array sizes (when arrays are defined in multiple configurations)
  • Accessibility and internationalization problems (hardcoded strings, missing contentDescription, etc)
  • Icon problems (like missing densities, duplicate icons, wrong sizes, etc)
  • Usability problems (like not specifying an input type on a text field)
  • Manifest errors

and many more.

336 questions
19
votes
1 answer

On Android Studio, the inspection "Unused resources" doesn't work for all modules on my project

I run it this way "Menu -> Analyze -> Run Inspection by Name -> Unused resources" and I select entire project but it doesn't find any unused resources outside my main App Module. So I then run it for individual modules and it finds stuff but it also…
casolorz
  • 8,486
  • 19
  • 93
  • 200
19
votes
3 answers

Kotlin and android lint checks

I am really loving to code android apps in Kotlin recently - but I really miss lint. Anyone knows how to get this back ( at least partially ). Is there a project that adapts the android java lint rules to kotlin? AFAIK lint is not running on…
ligi
  • 39,001
  • 44
  • 144
  • 244
18
votes
5 answers

META-INF/versions/9/module-info.class: broken class file? (This feature requires ASM6)

I'm having issues with Bouncycastle, which only arise when running the :lint task. Generally it seems to be a Java 9 byte-code version 53.0 / ASM version conflict. These are the dependencies: //…
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
17
votes
1 answer

Warning "Must be one of" - NotificationManager.IMPORTANCE

In Android Studio I get an error on new NotificationChannel(): Must be one of: android.app.NotificationManager.IMPORTANCE_HIGH, android app.NotificationManager.IMPORTANCE_LOW, ... But I reference exactly this. So it seems this is a bug in…
chrisonline
  • 6,949
  • 11
  • 42
  • 62
16
votes
1 answer

Context of lint.xml and inspection profile

In Android Studio there is the lint.xml configuration and ./idea/inspectionProfiles/.xml manageable via Settings => Editor => Inspections. I understand lint.xml is used by lint command line tool and the inspection profile is used by Android Studio…
16
votes
1 answer

How to fix Unprotected SMS BroadcastReceiver lint warning

My app needs to be able to receive SMS messages. It all works, but I get this lint warning: BroadcastReceivers that declare an intent-filter for SMS_DELIVER or SMS_RECEIVED must ensure that the caller has the BROADCAST_SMS permission, otherwise…
16
votes
3 answers

Activity not registered in the manifest Lint warning

I have a base activity from which I subclass several other activities. Those other activities I do register in the manifest so I can use them from within my application. However, Android inspection says, for my base activity, "Activity not…
Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
16
votes
1 answer

Android Lint: ignore library projects

I have a project which uses the ActionBarSherlock library. When I run Lint on my project, I get a lot of errors and warnings in ActionBarSherlock, which I don't care about. How can I run Lint only on my project, not the libraries it uses? (Note: I…
nhaarman
  • 98,571
  • 55
  • 246
  • 278
15
votes
1 answer

What is the right approach to "This AsyncTask class should be static or leaks might occur" in Kotlin Android?

There are many questions here dealing with This class should be static or leaks might occur in java android. This Handler class should be static or leaks might occur: IncomingHandler This Handler class should be static or leaks might…
user2829759
  • 3,372
  • 2
  • 29
  • 53
15
votes
2 answers

How to detect resource variable typos in Android Studio (ex: "%1$ s")

Android crashes are often caused by a resource containing %1$ s when %1$s was intended. To my surprise, Android Studio does not show these syntax errors: ↑ The real syntax error above is the %1$ s (makes the app crash), not the ellipsis that…
Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
15
votes
2 answers

Android API level annotation for Android libraries

I am writing an Android library. The vast majority of the interface in the lbirary supports Android API level 10 or above. Some functionality, though, requires a higher API level. For instance, part of the library requires API 18 for Bluetooth Low…
madmare
  • 153
  • 1
  • 1
  • 6
14
votes
1 answer

Make custom theme use null background (Android lint suggestion)

Im reading about the new Android Lint rules, and I find to prevent overdraw I should make my layouts with a background use a theme with null background, to prevent a background to be drawn if Im just gonna overwrite it. The problem is, how do I…
pgsandstrom
  • 14,361
  • 13
  • 70
  • 104
14
votes
4 answers

Prevent code accidentally going into production

I'm looking for a simple way to make sure my static final boolean DEBUG flag is set to false when exporting my Android project to APK. I've tried using the "STOPSHIP" comment marker mentioned here, but it doesn't seem to have any effect on apk…
Amir Uval
  • 14,425
  • 4
  • 50
  • 74
14
votes
7 answers

Strange Lint Warning - Unexpected text found in layout file: ""

I've got the following selector defined in button_selector.xml
Ginger McMurray
  • 1,275
  • 2
  • 20
  • 42
13
votes
1 answer

Android Suppress UnusedAttribute Warning For Specific Attributes

I have a few linter warnings for "UnusedAttribute" throughout my project. Attribute elevation is only used in API level 21 and higher (current min is 16) Attribute breakStrategy is only used in API level 23 and higher (current min is 16) Attribute…
mpkuth
  • 6,994
  • 2
  • 27
  • 44
1 2
3
22 23