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
1
vote
1 answer

Android Lint Config file - How to enable rules?

I have lint.xml file by default StopShip lint rule is disabled. --> StopShip is just…
Jay
  • 29
  • 4
1
vote
2 answers

How to get rid of deprecation warnings when providing backwards compatibility?

How one can get rid of linter deprecation warnings? For example, the annoying NetworkInfo: warning: [deprecation] NetworkInfo in android.net has been deprecated
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
1
vote
2 answers

Lint error with snackbar extension function

I have the following extension function to reduce a bit the code and to avoid forgetting the duration when showing a snackbar: fun Fragment.showSnackbar(text: String, length: Int = Snackbar.LENGTH_SHORT) { view?.run { Snackbar.make(this, text,…
1
vote
2 answers

How to disable this incorrect lint warning for a single code block?

I have a small code which gives an incorrect lint warning: int myfunc(@Nullable valStr) { int val = -1; if (!TextUtils.isEmpty(valStr)) { try { val = valStr.startsWith("1-"); //<== lint warning here :…
Afshin
  • 8,839
  • 1
  • 18
  • 53
1
vote
0 answers

Why Android Lint strictly discourages the use of Gravity.LEFT or Gravity.RIGHT?

I understand that texts may be LEFT or RIGHT on different languages, so that END or START may be useful for international apps. However, LEFT or RIGHT as Gravity are also simple placement of things. If I want my button or icon to be aligned to the…
htafoya
  • 18,261
  • 11
  • 80
  • 104
1
vote
0 answers

Unable to run Android Unit Test on Command Line After Upgrading Mockito and PowerMockito

After I upgraded our Unit Test Libraries Mockito to 3.2.0, PowerMockito to 2.0.4 I am unable to run the unit tests on the command line because of ByteBuddy. The tests pass on Android Studio but not on the command line because Mockito has a transient…
Val Okafor
  • 3,371
  • 13
  • 47
  • 72
1
vote
0 answers

Android Studio not finding unused resources

I have tried the methods explained on SO to remove unused strings, such as "Analyze...Run Inspection By Name...Unused Resources" and "Refactor....Remove Unused Resources" but the large majority of strings are not found. I search for these strings…
Steve M
  • 9,296
  • 11
  • 49
  • 98
1
vote
0 answers

Is it valid to publish an Android library with javax.inject as a dependency?

I'm writing an Android library that depends on a JVM library that depends on javax.inject. The default Android linter appears to disallow javax.inject as a (transitive) dependency for most Android libraries, but it whitelists it for Dagger and…
1
vote
1 answer

Android Lint error : Execution failed for task ':react-native-sensitive-info:lint'

I am using react-native-sensitive-info package in my project and I am facing an issue. Build fails with the following error Execution failed for task ':react-native-sensitive-info:lint'. I looked online and tried adding abortOnError false and also…
BRDroid
  • 3,920
  • 8
  • 65
  • 143
1
vote
1 answer

Custom Android Lint visiting method reference

I have working example of Detector which visits method calls by reference but it doesn't work for calls by method reference. class RxOnErrorDetector : Detector(), Detector.UastScanner { override fun getApplicableMethodNames() =…
Robertas Setkus
  • 3,075
  • 6
  • 31
  • 54
1
vote
1 answer

In Jetbrain IDEs, How to show warnings on method parameter hover?

In Android studio, If we write a log tag of more than 23 characters, it shows an underlined warning saying tag can't be more than 23 characters (pic for ref). If we want to do something similar to our own method (maybe while writing a new library),…
Sandesh Baliga
  • 579
  • 5
  • 20
1
vote
1 answer

How to suppress "UseSparseArrays" for a statement?

Some lints can be suppressed for a statement. E. g., "division by zero" lint: //noinspection divzero int i = 3 / 0; But some lints can't be suppressed for a statement in the same way. E. g.: //noinspection UseSparseArrays <-- Has no…
Andrii Lisun
  • 653
  • 4
  • 22
1
vote
1 answer

Cant generate signed apk,kotlin

After upgrading my Android Studio to 3.2.1, I encountered the following problem when creating Generate signed APK: Could not find lint-kotlin.jar (com.android.tools.lint:lint-kotlin:26.2.1). Searched in the following locations: …
1
vote
1 answer

Android Lint Error "Can't find API database; API check not performed"

When running Android Lint it outputs the following error "Can't find API database; API check not performed"
Steven Mark Ford
  • 3,372
  • 21
  • 32
1
vote
0 answers

Force method invocation in builder method

I have created a Builder class which initializes the Picasso library object in variety of ways, properties like gravity, resize(x,y) etc. In one particular case, if isCenterCropGravity(int gravity) is called. The gravity is operational if the resize…
Swapnil
  • 46
  • 7