[ERROR] When update sourceCompatibility and targetCompatibility to JavaVersion.VERSION_11

Hello @protoshadowmaker,

Thanks for your message and willingness to resolve the issue. I can understand your pain. The errors you see here don’t come from the scanner. These errors are coming from the Java Eclipse compiler (the one that we’re using to generate an AST and execute checks on Java files) This is happening because the compiler can’t resolve classes from java.lang package. This is most likely happening because Android has its own java.lang package and this is called Split-packages feature. It was working in Java 8 but isn’t allowed starting Java 9, when java modules appeared.

To double check this you can run, Gradle sonar task with an additional property -Dsonar.scanner.dumpToFile=out.properties. It won’t run the analysis but will save all your sonar properties into the file. And you need to share this file with me (if it contains secrets, make sure you removed them). I can also open a private conversation, so you can share it with me safely.

The potential solution to this problem could be to use sonar.java.jdkHome property (The Java analyzer relies on the JDK used to build your project and not the one used to run the scan) And as I can see it already solved a similar issue in another android project: Errors when running sonarqube-gradle-plugin:3.3 with Java 11

Please, read attentively the thread. A similar issue has already been solved and we have many users successfully using Java 11 with Android.

Best,
Margarita

1 Like