SonarLint Kotlin analyzer crashes on large Android project (Internal error / parse failure) but work

Hello Sonar team :waving_hand:,

I’m facing a persistent SonarLint analysis failure on a large Android project.
After extensive troubleshooting, this looks like a Kotlin analyzer incompatibility rather than a project misconfiguration.

I’ll try to be as precise and reproducible as possible.


Environment

• OS: macOS 26.2 (Apple Silicon)
• IDE: Android Studio Otter 3 Feature Drop | 2025.2.3
Build #AI-252.28238.7.2523.14688667 (Jan 9, 2026)
• Runtime: 21.0.8±14196175-b1038.72 (JetBrains)
• JVM: OpenJDK 64-Bit Server VM by JetBrains
• Memory: 5 GB
• Cores: 10
• Metal rendering: ON

Installed non-bundled plugins

• SonarLint for IntelliJ: 11.12.0.84088
• Snyk
• Anthropic Code plugin
• JetBrains Marketplace
• Full Line Completion


Project characteristics

• Android multi-module project
• ~900+ Kotlin source files
• Mix of Java + Kotlin
• Uses modern Kotlin features
• Gradle build syncs and compiles successfully
• No syntax errors (verified)


Kotlin / Gradle setup

• AGP: 8.10.0
• Kotlin versions tested:

  • 2.2.21
  • 2.1.21
    • KSP versions tested:
  • 2.2.20-2.0.3
  • 2.1.21-1.0.20
    • Gradle: 8.14.3
    • JDK for Gradle: Java 21 (Amazon Corretto / JetBrains runtime)

Build works fine in all cases.


The problem

SonarLint always fails during Kotlin analysis with an internal error.

Typical behavior:
• Java analysis completes successfully
• Kotlin analysis starts (hundreds of files)
• Analysis crashes with:

  • ResponseErrorException: Internal error
  • Error during analysis
    • Sometimes it hangs, sometimes it fails immediately

Relevant log excerpt:

[sonarlint-analysis-scheduler] INFO ProgressReport - 935 source files to be analyzed
… then analysis fails with internal error


Important observations

:check_mark: SonarLint works perfectly on:
• Small Android/Kotlin projects
• Same IDE
• Same SonarLint version
• Same machine

:cross_mark: SonarLint fails only on this large project.

:check_mark: Binding vs disconnected mode:
• Connected mode → fails
• Disconnected mode → fails
• Same result

:check_mark: Kotlin K2 mode:
• K2 OFF → analysis often hangs
• K2 ON → analysis progresses further but still crashes

:check_mark: File exclusions / scope limiting:
• Tried sonar.inclusions / sonar.exclusions
• Tried limiting to a single package
• Tried excluding build/, generated/, res/, assets/
• Analyzer still crashes globally

:check_mark: Cache & reinstall attempts:
• Removed all SonarLint caches
• Fully uninstalled plugin
• Deleted ~/.sonarlint
• Reinstalled plugin cleanly
• Same result

:check_mark: Comparison with teammate:
• Same repo
• Same SonarLint version
• Works on teammate’s machine
• Suggests environment + Kotlin analyzer interaction


What this suggests

This does not appear to be:
• A Gradle issue
• A Kotlin syntax issue
• A project configuration issue

It does appear to be:
• A Kotlin analyzer bug triggered by:

  • Project size
  • Specific Kotlin constructs
  • Or Kotlin/K2/IDE compatibility

Question

  1. Is there a known incompatibility between:

    • SonarLint Kotlin analyzer
    • Kotlin 2.1+ / 2.2+
    • Android Studio Otter 2025.2.x?
  2. Is there any way to:

    • Run Kotlin analysis incrementally?
    • Disable specific Kotlin rules?
    • Enable deeper debug logging for Kotlin parsing?
  3. Would providing a minimal reproducer (subset of files) help?

I’m happy to provide additional logs or isolate problematic files if needed.

Thanks a lot for your time and for maintaining SonarLint :folded_hands:

To help with reproducing this reliably, here are some additional observations and constraints that might clarify the behavior:


:magnifying_glass_tilted_left: Reproduction conditions that trigger the crash

:check_mark: This happens only on large Android projects with hundreds of Kotlin files.
:check_mark: On a small Kotlin project (same IDE + same SonarLint version + same machine) the analysis runs cleanly in all modes (connected / disconnected / K2 ON / K2 OFF).
:check_mark: On the large project (the real codebase), the crash always occurs when the Kotlin analysis attempts to start (after Java analysis finishes).


:test_tube: Attempts already made

These steps have already been tried and all produce the same crash:

  1. Clean reinstall of SonarLint plugin

    • Uninstalled plugin
    • Deleted ~/.sonarlint
    • Deleted Android Studio SonarLint caches
    • Reinstalled SonarLint
    • Same crash
  2. Clearing all IDE caches

    • Invalidate Caches / Restart
    • Same crash
  3. Multiple Kotlin / KSP versions

    • Kotlin 2.2.21
    • Kotlin 2.1.21
    • KSP variants compatible
    • Gradle sync / compile works
  4. JDK alignment

    • Gradle JDK = Java 21 (matches IDE)
    • Build success is unaffected
  5. Analysis variations

    • Connected (binding) → crash
    • Disconnected → crash
    • K2 OFF → often hangs before crash
    • K2 ON → progresses further then crash
  6. Inclusions / exclusions adjusted

    • sonar.inclusions, sonar.sources, sonar.exclusions tried
    • Still crash when analyzer reaches Kotlin files
  7. Scoped analysis

    • Attempted to analyze only specific folders via IDE context menu
    • Still crashes (analyzer still indexed entire module)

:pushpin: What doesn’t appear to be the cause

:cross_mark: Not a Gradle build error
:cross_mark: Not a pure syntax issue (small test cases compile)
:cross_mark: Not a caching leftover
:cross_mark: Not solely a plugin install issue
:cross_mark: Not a JVM mismatch


:puzzle_piece: Additional context

• Android Studio Otter 3 Feature Drop | 2025.2.3
Runtime: Java 21.0.8
macOS 26.2 (arm64)

• SonarLint 11.12.0

• Java analysis always completes successfully
• Kotlin analysis always reaches hundreds of files before crashing

• Logs indicate:


INFO ProgressReport - X source files to be analyzed
… then internal error / parser failure

• Teammate on same project + same SonarLint + same IDE version does not see the crash — so environment alone likely isn’t the full cause.


:red_question_mark:Questions that would help pinpoint the issue

  1. Is there a known limitation in sonar-kotlin analyzer for large Kotlin codebases?
  2. Are there specific Kotlin/K2 constructs that cause internal parser failures in SonarLint?
  3. Are there flags to run Kotlin analysis with more logging (DEBUG/TRACE) that can expose where the crash happens?
  4. Could this be a memory/streaming issue when indexing large Kotlin sources?
  5. Is there a way to disable just the Kotlin analyzer in SonarLint to narrow down the execution?

I can provide more logs (debug), a minified repro, or GitHub access snippet if needed.

Happy to help further to nail this down :flexed_biceps:

Hi,

Welcome to the community and thanks for this very thorough report!

Could you give us a verbose log from IDE startup through to the error, please?

 
Thx!
Ann

Diagnostics Report 2026 02 03 - 084218.zip (809.9 KB)

sonarlog.txt (1 MB)

Hi Ann,

I collected a full diagnostic report using Help → Collect logs and diagnostic data, and I’m attaching it (zip).
I’m also attaching the Sonar log output from the IDE (sonarlog.txt).

The Kotlin analysis fails on multiple .kt files with:
null cannot be cast to non-null type org.jetbrains.kotlin.psi.KtFile
e.g. EditSaleActivity.kt, CountriesModel.kt, etc.

Environment: Android Studio Otter 3 Feature Drop (2025.2.3), SonarQube for IDE 11.12.0, macOS aarch64.

Thanks!

1 Like

Hi,

Thanks! This is flagged for the team.

 
Ann

Thanks, Ann!
I’ll wait for your team’s feedback. Let me know if you need any additional logs or tests on my side. :slight_smile:

1 Like