Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Lint infrastructure error when lint baseline file is configured in android build

Tags:

android

lint

I am getting the following exception when I enable lint with baseline file configuration.

> Lint infrastructure error
  Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.........................
.........................
 Caused by: java.lang.IllegalStateException: path must not be null
        at com.android.tools.lint.XmlReporter.writeIssue(XmlReporter.kt:209)
        at com.android.tools.lint.XmlReporter.writeIssues(XmlReporter.kt:113)
        at com.android.tools.lint.XmlReporter.write(XmlReporter.kt:99)
        at com.android.tools.lint.LintCliClient.run(LintCliClient.java:288)

I added following lintOptions in my module build.gradle

After which I ran lintDebug gradle task.


    android{
        lintOptions {
            baseline file("lint-baseline.xml")
            warningsAsErrors true
            abortOnError true
        }
    }

I was expecting my changes to create lint-baseline.xml file in module root directory for the first run and fail the build indicating creation of lint-baseline.xml. For the second run the lint should read lint-baseline.xml and suppress the existing error/warning reporting.

But the first run creates empty lint-baseline.xml and fails with Lint infrastructure error. The subsequent runs did not produce Lint infrastructure error but because the file is empty, the comparison fails resulting in errors/warnings.

My app has both java and kotlin files.

like image 338
Atik Avatar asked Apr 22 '19 06:04

Atik


People also ask

What is lint error Android?

The lint tool checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. When using Android Studio, configured lint and IDE inspections run whenever you build your app.

How do you check for lint errors?

Module and file-specific preferences Run the lint tool on your module by right-clicking on your module folder or file in the Project View and selecting Analyze > Inspect Code. This displays the lint inspection results with a list of issues that lint detected in your module.

How do you use lint on Android?

To utilize Lint or just run inspections in your project, add Lint inspection to the lint. xml file or manually pick the list of issues to be configured by Lint in your project using Android Studio. Configure the lint file: Add the list of issues to be configured in the lint.

What are lint warnings?

In many cases, lint warns you about incorrect, error-prone, or nonstandard code that the compiler does not necessarily flag. The lint program issues every error and warning message produced by the C compiler. It also issues warnings about potential bugs and portability problems.


2 Answers

i had this same issue, deleting the 'build' and 'release' folders. Somehow that worked for me. Don't know what actually caused it.

like image 163
Bhrugu Tundeliya Avatar answered Oct 13 '22 00:10

Bhrugu Tundeliya


This might not be the best answer, but I tried, adding an old output.json into the APK destination folder and tried to build a signed apk, then the error was known, in which we have to delete the output.json file. This time after building the APK, it worked.

Again on the other day, the above method failed, I tried deleting the release folder and creating the APK again. This time it worked.

like image 41
GiridharaSPK Avatar answered Oct 13 '22 01:10

GiridharaSPK