Atik
Atik

Reputation: 131

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

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.

Upvotes: 13

Views: 9258

Answers (4)

Ali Maddi
Ali Maddi

Reputation: 339

If the lint process successfully finished, you would get a appropriate result lint file. The error you get, shows the lint process has been failed in the first lint process run. After first run, the tools only read the empty file to determine the baseline. According to the reference you need manually delete the file and run lint process again to recreate it. for more information you can use "Analyze > Inspect Code" in menu on the Android Studio IDE or use command line with command :

$ ./gradlew lintDebug

in both manner you can find the location of the lint-baseline.xml as output

...

Wrote XML report to file:///app/lint-baseline.xml
Created baseline file /app/lint-baseline.xml

pay attention if you use command line in the terminal of Android Studio, you must use Ctrl + Enter for running the command. The output shows you a lot of useful information for debugging the problems.

Upvotes: 1

Rakshit Kothari
Rakshit Kothari

Reputation: 26

I also faced the same issue and tried all solutions. Later, I realized there was an issue in a CSV plugin for Android Studio I installed. Since I disabled the plugin and restart the android studio, everything is working fine.

Upvotes: -1

Bhrugu Tundeliya
Bhrugu Tundeliya

Reputation: 160

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

Upvotes: 3

GiridharaSPK
GiridharaSPK

Reputation: 547

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.

Upvotes: 4

Related Questions