Problem compiling android kotlin project with gradle

hi there.

i have same error
my SonarQube version is = Version 9.9.2 (build 77730)
JDK version = 17

sonarqube {
    androidVariant 'release'
    properties {
        property "sonar.projectName", "Digital-Android"
        property "sonar.host.url", "https://sonar.****.am/sonarqube"
		property "sonar.projectKey", "*************"
        property "sonar.login", "***************"
        property "sonar.sources", "./src/main/java"
        property "sonar.qualitygate.wait", "true"

    }
}

Who can help me?

i have writed new post, but no any answer

Hi,

What version of the SonarScanner for Gradle are you using?

And are you having this problem during your compile, or during the compile that the SonarScanner for Gradle triggers?

Version 4.4.1 of the scanner introduces the sonar.gradle.skipCompile property, although it needs to be set as a system property.

 
HTH,
Ann

i have added this property in sonarqube task, and change version to 4.4.1 but same error

sonarqube {
    androidVariant 'release'
    properties {
        property "sonar.projectName", "test-Android-Project"
        property "sonar.host.url", "*"
        property "sonar.projectKey", "*"
        property "sonar.login", "*"
        property "sonar.sources", "src/main/java"
        property "sonar.language", "kotlin,java"
        property "sonar.verbose", "true"
        property "sonar.qualitygate.wait", "true"
        property "sonar.gradle.skipCompile", "true"

    }
}

Hi,

Sorry, for the confusion. I’ve since learned that the problem here isn’t happening during compilation, but during the Analysis.

This happens when we analyze Java files during the Eclipse Compiler frontend invocation. This is a known issue with ECJ (Eclipse compiler), Android, and our analyzer. because ECJ is more strict in following Java language specifications than other compilers and here technically Android violates Java language specifications (JLS).

At the moment the workaround is to set jdkHome to Java 8 (even if they’re using a different Java version). This works because Java 8 is the last non-modularized Java version.

And we’re working on a better fix.

 
Thx,
Ann

Thank you for your response.

Now, I need to update the sonarqube task to use Java 8. How can I make this change, or what steps should I take to fix this?

I have added the sonar.java.jdkHome property, set it to the path of JRE 8, and it works for me. Thank you so much!

property "sonar.java.jdkHome", "C:\\Program Files\\Java\\openjdk-jre-8\\bin"

1 Like

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