Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android lint is ignoring my lint.xml, skipping checks I am trying to enable

Tags:

android

lint

I am trying to use Android lint to check some things about my project. It seems to be ignoring the lint.xml file that I am giving it, making it impossible for me to enable checks.

I am using Android Studio on Ubuntu 14.04, but I am just calling ~/Android/Sdk/tools/lint from the command line.

I am doing:

 $ lint --config GF/lint.xml --html lintCheck.html GF   
 Scanning 7.5.0: .
 Scanning 7.5.0 (Phase 2): 
 ... (and so on) ...
 Wrote HTML report to file:/home/ray/Projects/jj/lintCheck.html
 Lint found 26 errors and 198 warnings
 $ 

The report lists all of the checks that are not enabled. Here is the GF/lint.xml file that I created:

 $ cat GF/lint.xml 
 <?xml version="1.0" encoding="UTF-8"?>
 <lint>
     <issue id="HardcodedText" severity="error" />
 </lint>
 $

Here are the ways I have tried to call lint. In all of these cases, all of the checks say something like:

 RelativeOverlap
 Disabled By: Project lint.xml file

So, where is the project lint.xml file that it is referring to? I have searched in ~/Android and in all my projects and this file does not appear anywhere else.

RelativeOverlap Disabled By: Project lint.xml file

What I have tried:

 $ lint  --ignore MissingTranslation -Wall --html lintCheck.html GF
 $ lint  --ignore MissingTranslation -Wall --enable all --html lintCheck.html GF
 $ lint  --ignore MissingTranslation -Wall --enable Correctness,Security,Performance,Usability --html lintCheck.html GF
 $ lint  --ignore MissingTranslation -Wall --enable Correctness --html lintCheck.html GF
 $ lint  --ignore MissingTranslation -Wall --enable RelativeOverlap --html lintCheck.html GF
 $ lint --enable RelativeOverlap --html lintCheck.html GF
 $ lint --config GF/lint.xml --html lintCheck.html GF
 $ lint --config GF/lint.xml --html lintCheck.html GF

Any suggestions would be appreciated.

like image 574
Ray Kiddy Avatar asked Aug 06 '15 19:08

Ray Kiddy


People also ask

How do I run lint on Android?

Run lint using the standalone tool If you're not using Android Studio or Gradle, you can use the standalone lint tool after you install the Android SDK Command-Line Tools from the SDK Manager. You can then locate the lint tool at android_sdk /cmdline-tools/ version /bin/lint .

What is lint error android?

Android Studio provides a code scanning tool called lint that can help you to identify and correct problems with the structural quality of your code. For example, Lint can help us clean up these issues. XML resource files containing unused namespaces. Use of deprecated elements.

What is lintOptions?

lintOptions { abortOnError false } This means it will run lint checks but won't abort the build if any lint error found. By default, its true and stops the build if errors are found.


1 Answers

Configure the lint-options in gradle file for the lint.xml to be picked up

lintOptions {
        // set to true to turn off analysis progress reporting by lint
        quiet true
        // if true, stop the gradle build if errors are found
        abortOnError false
        // do not ignore warnings
        warningsAsErrors true
        lintConfig file('lint.xml')
    }

just put the above lintoptions in the build.gradle file of app folder

And place the lint.xml file in the app folder itself then it will be picked up

here is a screenshot of placement in studio directory:enter image description here

like image 128
Amal p Avatar answered Sep 27 '22 18:09

Amal p