# Android Java 17 scanner crash

**URL:** <https://community.sonarsource.com/t/android-java-17-scanner-crash/104073>\
**Category:** SonarQube Cloud\
**Tags:** android, java, scanner\
**Created:** [November 9, 2023, 9:41am UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073 "2023-11-09T09:41:17Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidFaermanPendo](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/davidfaermanpendo/32/29261_2.png) [@DavidFaermanPendo](https://community.sonarsource.com/u/DavidFaermanPendo)\
**Post date:** [November 9, 2023, 9:41am UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/1 "2023-11-09T09:41:17Z")

</div>

Hello,  
I am facing the same problem a lot of other Android developers are facing.  
ECJ Unable to resolve type android.content.ContentProvider  
org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(347) The type java.lang.String cannot be resolved. It is indirectly referenced from required type android.content.ContentProvider  
at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:162)  
I was not able to find a proper solution the only workaround I found is to set `sonar.java.jdkHome` to a Java 8 JDK.

Is this a good practice?  
Would I get the correct deprecation warnings?  
My source code compatibility is iset to Java 11 and I am forced to that because of our business.

What really call my attention is I was using Java 11 and used to have the compatibility to Java 8 and everything worked correctly… moved to java 17 and set the compatibility to java 11 and everything went down hill.

is there any other workaround?  
Are you planning any other solution?  
Thanks!!!

---

<div class="post-metadata">

**Author:** ![DavidFaermanPendo](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/davidfaermanpendo/32/29261_2.png) [@DavidFaermanPendo](https://community.sonarsource.com/u/DavidFaermanPendo)\
**Post date:** [November 13, 2023, 10:12am UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/3 "2023-11-13T10:12:22Z")

</div>

a comment to keep this open

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [November 15, 2023, 6:16pm UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/4 "2023-11-15T18:16:17Z")

</div>

Hello @DavidFaermanPendo ,

When you say “source code compatibility” are you talking about `sourceCompatibility` in build.gradle?

Just so I make sure I understand:

- When you set `sourceCompatibility` to Java 8 and run the Sonar scan with Java 11, it works.
- When you set `sourceCompatibility` to Java 11 and run the Sonar scan with Java 17, it fails.

Is that correct?

Also, can you please confirm if you are facing a similar issue as this thread?

> [[ERROR] When update sourceCompatibility and targetCompatibility to JavaVersion.VERSION\_11](https://community.sonarsource.com/t/error-when-update-sourcecompatibility-and-targetcompatibility-to-javaversion-version-11/98106)

There are several workarounds that may help you including setting `sonar.java.jdkHome` at the module’s build.gradle Please review that thread and let me know if you have further questions.

---

<div class="post-metadata">

**Author:** ![DavidFaermanPendo](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/davidfaermanpendo/32/29261_2.png) [@DavidFaermanPendo](https://community.sonarsource.com/u/DavidFaermanPendo)\
**Post date:** [November 16, 2023, 8:14am UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/5 "2023-11-16T08:14:40Z")

</div>

Hi,  
Yes in build.gradle  
Yes, it is the same problem. The workaround setting sonar.java.jdkHome to java 8, I read it in that thread.

about sourceCompatibility looks like is not that simple to roll back, there are more chances in the code and I can not just change the sourceCompatibility to java 8. Also because our business I am lock in Java 11 compatibility.

Yes, I do have further questions:

Is this a good practice?  
Would I get the correct deprecation warnings?  
is there any other workaround?  
Are you planning any other solution?

This looks to be a very well documented problem because googling sonarclour/sonarqube android the first page is ppl asking about this.  
Thanks

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [November 17, 2023, 1:19pm UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/10 "2023-11-17T13:19:45Z")

</div>

Hi @DavidFaermanPendo,

No, it is not good practice. Setting `sonar.java.jdkHome` to Java 8 is purely a workaround until we fix the issue in [[SONARJAVA-4697] - Jira](https://sonarsource.atlassian.net/browse/SONARJAVA-4697). The priority of this ticket is critical as you can see, so it is actively being worked on as we type.

Note that setting `sonar.java.jdkHome` won’t change the Java version of your project so you can use whatever Java version you want. Please see [Java: Project’s Specific JDK](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/languages/java/#project-specific-jdk) for more info.

---

<div class="post-metadata">

**Author:** ![DavidFaermanPendo](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/davidfaermanpendo/32/29261_2.png) [@DavidFaermanPendo](https://community.sonarsource.com/u/DavidFaermanPendo)\
**Post date:** [November 19, 2023, 8:45am UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/11 "2023-11-19T08:45:38Z")

</div>

Joe, how are you?  
Thank you very much for the update!!!  
Went over the ticket, and it looks amazing. I have a question, it mentions it will be fixed in version 7.29, to what version of the Gradle plugin is this related? So I can keep an eye on it and update when this is released.  
Thanks!!!

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [November 19, 2023, 1:43pm UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/12 "2023-11-19T13:43:40Z")

</div>

@DavidFaermanPendo I’m doing well, thanks!

The fix is in the Sonar Java language analyzer, not the Gradle Sonar Scanner, so 7.29 corresponds most likely with SonarQube 10.4.

---

<div class="post-metadata">

**Author:** ![DavidFaermanPendo](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/davidfaermanpendo/32/29261_2.png) [@DavidFaermanPendo](https://community.sonarsource.com/u/DavidFaermanPendo)\
**Post date:** [November 20, 2023, 11:08am UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/13 "2023-11-20T11:08:30Z")

</div>

Thanks for your reply!!!  
To what can I subscribe or what should I check to know when the fix is released?  
again thanks!  
David

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [November 20, 2023, 4:56pm UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/14 "2023-11-20T16:56:38Z")

</div>

> [@DavidFaermanPendo](#):
>
> To what can I subscribe or what should I check to know when the fix is released?

Hi David!

The easiest way to be notified of SonarQube releases is to subscribe for product release updates. There are two quick ways to do it:

1. Add your email (bottom of the [SonarQube | What's new](https://www.sonarsource.com/products/sonarqube/whats-new/)) to get email updates
2. Go to [Sonar Community’s SonarQube Releases](https://community.sonarsource.com/c/sq/releases/24) topic and click on the bell icon to “Watching” to get email updates

SonarQube 10.4 should probably be released around early 2024.

---

<div class="post-metadata">

**Author:** ![DavidFaermanPendo](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/davidfaermanpendo/32/29261_2.png) [@DavidFaermanPendo](https://community.sonarsource.com/u/DavidFaermanPendo)\
**Post date:** [November 21, 2023, 7:53am UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/15 "2023-11-21T07:53:36Z")

</div>

Hi,  
And for SonarCloud?  
Can this be released earlier? Early 2024 can be in 2 months from now or in 6 months from now.  
Thanks

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [November 21, 2023, 3:30pm UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/16 "2023-11-21T15:30:06Z")

</div>

Early 2024 means Q1 2024 but that’s tentative.

For SonarCloud, we perform new releases at least on a weekly basis, but I can’t tell when [Sonar Java](https://github.com/SonarSource/sonar-java) will be released. You can click on “Watch” and select releases from custom notifications so once ~~7.29~~ 7.30 or greater is released, you’ll be notified and it should be released on SonarCloud subsequently.

---

<div class="post-metadata">

**Author:** ![DavidFaermanPendo](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/davidfaermanpendo/32/29261_2.png) [@DavidFaermanPendo](https://community.sonarsource.com/u/DavidFaermanPendo)\
**Post date:** [December 27, 2023, 8:56am UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/17 "2023-12-27T08:56:03Z")

</div>

Hello,  
I saw the new Sonar Java was released with this fix inside. THANK!!!  
Quick question: how do I know, or how can I make Sonarcloud use the latest version for the scan?  
Is it automatic? Do I need a new version of Sonarcloud? Can I configure it somewhere?  
Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Joe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joe/32/14820_2.png) [@Joe](https://community.sonarsource.com/u/Joe)\
**Post date:** [December 27, 2023, 3:23pm UTC](https://community.sonarsource.com/t/android-java-17-scanner-crash/104073/18 "2023-12-27T15:23:57Z")

</div>

You’re welcome!

By default, SonarCloud will use the latest version in most cases. It is automatic. There is no version of SonarCloud that you can control. Sonar controls the version of the language analyzers. You cannot configure that.
