Android Gradle Build & Analyze failed on Lint errors

Hi all,

We’re currently struggling with setting up the SonarCloud project for Android (Java/Kotlin combined).
When adding the project, upon extra configuration we’ve selected Github Action.
It fails after running 8-9 minutes in the Build and analyze job in the (default) Github workflow yaml:

      - name: Build and analyze
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: ./gradlew build sonarqube --info

It fails with the following:

Lint found 36 errors, 197 warnings. First failure:

/home/runner/work/ Error: xxxxx

The full lint text report is located at:
:app:lintDebug (Thread[Execution worker for ':',5,main]) completed. Took 0.003 secs.
Android Lint: Disposing Uast application environment in lint classloader [30.2.2]

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lintDebug'.
> Lint found errors in the project; aborting build.

The project compiles and runs fine locally (APK with current code also running fine in the PlayStore), but gives this error in the Github Action build, preventing the analysis to be shown in SonarCloud.

What we would expect is the build step to ignore these errors and mark them so they are shown in SonarCloud which we can then use to go through all errors and fix them (as in our PHP & iOS projects).

How can we achieve this, or should we not achieve this at all but have a go at it in a different way (first solving all 36 errors as shown by LintDebug in Github Action log is not desired).

Thanks for your reactions!

Hey there.

At this point in your build, SonarCloud hasn’t done anything (if you removed the sonarqube task, it would still fail). You should probably check the documentation for AndroidLint about continuing on these errors, or understanding why they show up in a GH Actions context and not locally.

Thanks, wasn’t aware of that, have it working now!

Actually, still no results in SonarCloud.
I see the following in the log:
Skipping SonarQube analysis: no properties configured, was it skipped in all projects?

But have added this is the apps project build.gradle, just below the buildscript {} :

plugins {
    id "org.sonarqube" version ""

sonarqube {
    properties {
        property "sonar.projectKey", "xxxx"
        property "sonar.organization", "xxxx"
        property "", ""

Are there more steps that I am missing?
GH Action uses Gradle 7.3.3

There shouldn’t be. If you add --info or --debug to your gradle command, do you see more information about the sonarqube task?

After some puzzling the build was successful, I found the following error in the link to the task on sonarcloud, which makes sense and it is solved now. Thanks!

"errorMessage":"This analysis will make your organization \u0027safedrivepod\u0027 to reach the maximum allowed lines limit (having 118541 lines).

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.