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
4
votes
1 answer

Custom android lint rules not being executed

I have created two custom lint rules and verified that they work as expected with unit tests. However, when I try to run lint on the whole project with ./gradlew app:lint these rules are not executed. To verify that they are not executed I debugged…
lotdrops
  • 300
  • 5
  • 16
4
votes
2 answers

MissingConstraints lint error when using Flow

I'm using the recently released constraint layout version 2.0 and they have added a new feature called Flow which basically replaces what linear layout used to do ( with more customization ). But the android lint is blocking my CI from building…
Brook MG
  • 601
  • 10
  • 20
4
votes
0 answers

Android custom lint rule for handling java checked exception in kotlin

Since kotlin doesn't have the concept of the checked exception, many times we tend to forget about handling the exception while calling the java function(from kotlin) which throws checked exception and it would just crash in case of exception. Since…
Ashraf Patel
  • 699
  • 1
  • 7
  • 17
4
votes
1 answer

Android lint AnnotationProcessorOnCompilePath with ButterKnife

After upgrading to latest Android gradle plugin: classpath 'com.android.tools.build:gradle:3.6.1' Android lint (./gradlew lint) getting following warning: Warning: Add annotation processor to processor path using annotationProcessor instead of…
IliaEremin
  • 3,338
  • 3
  • 26
  • 35
4
votes
1 answer

How to get qualified name of an UAnnotation from Java source code?

I am trying to write a simple Android lint check, which make sure you use a specific nullability annotation. But for some reason, I am not able to get the fully qualified name of the annotation. Here's the test case: val input = """ package…
Louis Tsai
  • 1,587
  • 3
  • 20
  • 33
4
votes
1 answer

How to suppress Lint warnings in generated sources?

With Room version 2.1.0-alpha04: implementation "androidx.room:room-runtime:2.1.0-alpha04" annotationProcessor "androidx.room:room-compiler:2.1.0-alpha04" testImplementation "androidx.room:room-testing:2.1.0-alpha04" The @Dao implementations of the…
4
votes
1 answer

Android @SuppressWarnings at statement-level, rather than method-level

TL;DR: Can Android's @SuppressWarnings("deprecation"), or similar, be applied to a single statement, rather than an entire method? I have a method myMethod that uses deprecated method ImageView.setAlpha(): public void myMethod(ImageView icon) {…
4
votes
1 answer

Android Studio 3.0 lint not finding missing permissions

I have a few places in my code where state of permissions is not properly checked before the function requiring a permission is called. As a result I'm getting random SecurityException reports as my users encounter unprotected function calls. (long…
velis
  • 8,747
  • 4
  • 44
  • 64
4
votes
1 answer

How to configure Lint to ignore google-services.json?

How should Lint be configured to ignore the Firebase config file, particularly spell check? The google-services.json file is in the "app" module folder. build.gradle (app) lintOptions { lintConfig file('lint.xml') } The following…
Ollie C
  • 28,313
  • 34
  • 134
  • 217
4
votes
4 answers

How to create flavor specific Android Lint baseline file

As per https://developer.android.com/studio/write/lint.html#snapshot we can create a Lint warning baseline file. The problem is that I have multiple flavors, each having their own sourceSets. Some files are used in a single flavor. When I generate…
4
votes
0 answers

Android android.lintOptions.abortOnError for release builds only

I'd like to set strict lint checking on my CI and it would be nice if I could set the abortOnError bit for lint only when I run a release build. I've tried: compileLint.doFirst { android.applicationVariants.each { variant -> …
TheHebrewHammer
  • 3,018
  • 3
  • 28
  • 45
4
votes
2 answers

Android Lint "is not a valid format string" error in string of xml file

I want to display such a title in my screen, "Up to 30% cheaper". So, I have this in my xml file: Up to %d%% cheaper and In code: mTitle.setText(getString(R.string.title, 30)); Although it works fine and I see above…
Hesam
  • 52,260
  • 74
  • 224
  • 365
4
votes
2 answers

RequiresPermission annotation 'only specify one of value, anyOf or allOf'

Trying to apply the @RequiresPermission annotation as explained in tech-docs. The example shows If you require at least one from a set of permissions, you can use the anyOf attribute: @RequiresPermission(anyOf = { …
4
votes
0 answers

Install referrer receiver was accidentally left in the manifest file after I removed the referrer SDK

I have removed the appnext SDK from my project. However, I forgot to remove the appnext install referral receiver. The version passed gradle build without any error or warning even though it should have failed the build! (Since I referenced an SDK…
4
votes
1 answer

What are the default values for lintOptions?

Where can the default values for lintOptions be found? I have found the documentation here but I cannot find what these values are by default
Daiwik Daarun
  • 3,804
  • 7
  • 33
  • 60