This bug seems to be fixed as of this commit. Update Intellij to get the new version.

If you can't update, a workaround to this is removing gradle aware make from the run process, and only build your code when you make a change (and not every time you start the debug)

Explanation to fix:

Hitting breakpoints in Kotlin JUnit test with an Android Gradle
project sometimes(*) does not work in Android Studio 3.1 beta.

(*) The issue is related to various threads running concurrently
with "dumb" mode background code, so the issue reproduces only
on certain configurations.

In a nutshell, the issue is as follows

* On one hand, gradle build finishes, fires an event ("buildFinished")
  that is processed "later" and that causes the IDE to enter "dumb" mode
  for a shot amount of time (about 300-500 msec on a somewhat up to date
  multi-core computer).

* On the other hand, once the JVM of the debuggee is started, breakpoints
  need to be resolved (on the debugger thread, through a call to
  com.intellij.debugger.engine.CompoundPositionManager.createPrepareRequests.
  This code calls into the "KotlinPositionManager.createPrepareRequests",
  which in turns calls into "PerFileAnalysisCache.analyze". That method
  returns "AnalysisResult.EMPTY" is the project is in dumb mode.
  This return value prevents callers from successfully resolving
  the source location into a breakpoint.

Given that the 2 code paths above execute on separate threads without
explicit synchronization, the "failed to resolve breakpoint" issue
occurs sporadically, to the point it happens 100% of the time on
certain configuration.

The fix is so wrap the kotlin breakpoint resolution code inside
a "runReadActionInSmartMode" so that the debugger thread "waits"
for "dumb" mode to terminates before trying to resolve breakpoint
locations.
Answer from LeoColman on Stack Overflow
🌐
Kotlin Discussions
discuss.kotlinlang.org › support
Tons of problems with the debugger and Kotlin - Support - Kotlin Discussions
June 17, 2019 - I am running on 2019.1.3 built on May 28th. Basically what happens is breakpoints are not detected, often IDE doesn’t stop and keeps running. Have to try a few times (rerun the app) to make it detect the breakpoints.
🌐
Kotlin Discussions
discuss.kotlinlang.org › support
Breakpoints not hit anymore on Windows - Support - Kotlin Discussions
January 25, 2018 - I have a weird problem that recently started (still need to figure out exactly when) in a project using Kotlin 1.2.20 / 1.2.21, Gradle 4.4.1 / 4.5, and kotlintest 2.0.7. For some reason, IntelliJ does not hit breakpoints anymore, but only on Windows: All breakpoints say “Breakpoint does not belong to any class”. The exact same project still works on Linux.
Top answer
1 of 1
2

This bug seems to be fixed as of this commit. Update Intellij to get the new version.

If you can't update, a workaround to this is removing gradle aware make from the run process, and only build your code when you make a change (and not every time you start the debug)

Explanation to fix:

Hitting breakpoints in Kotlin JUnit test with an Android Gradle
project sometimes(*) does not work in Android Studio 3.1 beta.

(*) The issue is related to various threads running concurrently
with "dumb" mode background code, so the issue reproduces only
on certain configurations.

In a nutshell, the issue is as follows

* On one hand, gradle build finishes, fires an event ("buildFinished")
  that is processed "later" and that causes the IDE to enter "dumb" mode
  for a shot amount of time (about 300-500 msec on a somewhat up to date
  multi-core computer).

* On the other hand, once the JVM of the debuggee is started, breakpoints
  need to be resolved (on the debugger thread, through a call to
  com.intellij.debugger.engine.CompoundPositionManager.createPrepareRequests.
  This code calls into the "KotlinPositionManager.createPrepareRequests",
  which in turns calls into "PerFileAnalysisCache.analyze". That method
  returns "AnalysisResult.EMPTY" is the project is in dumb mode.
  This return value prevents callers from successfully resolving
  the source location into a breakpoint.

Given that the 2 code paths above execute on separate threads without
explicit synchronization, the "failed to resolve breakpoint" issue
occurs sporadically, to the point it happens 100% of the time on
certain configuration.

The fix is so wrap the kotlin breakpoint resolution code inside
a "runReadActionInSmartMode" so that the debugger thread "waits"
for "dumb" mode to terminates before trying to resolve breakpoint
locations.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360003676199-Can-t-debug-any-Java-or-Kotlin-application
Can't debug any Java or Kotlin application – IDEs Support (IntelliJ Platform) | JetBrains
Setting a breakpoint on each print ... but does not stop at breakpoints. ... - Checked that breakpoints are unmuted - Invalidated caches - Tried both JRE 1.8 and JRE 10 to run the Debug Configuration · The problem persists on both Windows machines I'm working on, with separate IntelliJ instances, ...
🌐
GitHub
github.com › bazelbuild › intellij › issues › 2832
Breakpoint doesn't work for Kotlin in IntelliJ IDEA 2021.2 · Issue #2832 · bazelbuild/intellij
August 5, 2021 - Open rules_kotlin project and place a breakpoint in a test, such as testSrcJarGeneration in src/test/kotlin/io/bazel/kotlin/KotlinJvmBasicAssertionTest.kt, then debug the test class using the icon on the gutter. ... Actual: Test finished with all cases passed. With plugin 2021.07.13.0.1 in IntelliJ IDEA 2021.1.3, it works ...
Author   jameslan
🌐
GitHub
github.com › gradle › kotlin-dsl-samples › issues › 1040
KT-23526 - IntelliJ debugger ignores breakpoints in Kotlin scripts · Issue #1040 · gradle/kotlin-dsl-samples
August 14, 2018 - KT-23526 The debugger doesn't ignore breakpoints in class and object members so a workaround is to declare an object in the script and put the breakpoint there: Top-level breakpoint in line 10 above is ignored but the breakpoint in line ...
🌐
JetBrains
jetbrains.com › help › idea › debug-your-first-kotlin-application.html
Tutorial: Debug your first Kotlin application | IntelliJ IDEA Documentation
October 23, 2024 - After the debugger session has started, the program runs normally until a breakpoint is hit. When this happens, IntelliJ IDEA pauses the program, highlights the line at which the program is suspended, and shows the Debug tool window. The highlighted line has not been executed yet.
Find elsewhere
🌐
JetBrains
jetbrains.com › help › idea › using-breakpoints.html
Breakpoints | IntelliJ IDEA Documentation
2 weeks ago - Once the count completes, it resets and starts again. This means that if Pass count is set to 10, the breakpoint will work every tenth time it is hit. If both Pass Count and Condition are set, IntelliJ IDEA first satisfies the condition and then checks for Pass Count.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 23019611189906-How-can-I-set-a-breakpoint-into-Kotlin-default-constructor
How can I set a breakpoint into Kotlin default constructor – IDEs Support (IntelliJ Platform) | JetBrains
December 2, 2024 - According to https://www.jetbrains.com/help/idea/using-breakpoints.html#set-breakpoints, you can set a breakpoint for the default class constructor by clicking on class declaration line · To suspend the program when the default constructor of a class is called, click the gutter at the line where the class is declared · However, it doesn't work with Kotlin files (.kt).
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 22113723485458-Debugging-React-Native-Typescript-JSX-Kotlin-doesn-t-hit-breakpoints
Debugging React Native Typescript JSX + Kotlin doesn't hit breakpoints – IDEs Support (IntelliJ Platform) | JetBrains
October 21, 2024 - In the second video, as you can see, I added a local native module where the sample templates added just a multiply function and as you can see I put a breakpoint on kotlin function which IntelliJ should support 100% but it didn't even stopped the execution to let me check variables in that function, like that toAdd variable…I tried to add also debugger” line code because maybe it would make IntelliJ's debugger see it and stop execution but seems “debugger” is not recognized by Kotlin compilation… · And as I said in previous stop, if I am debugging so putting a breakpoint, the debugger should just see that breakpoint and stop the execution there… · Maybe there is something I have to configure somewhere in IntelliJ to make the debugger working properly and stop on any breakpoint there is.
🌐
Kotlinlang
slack-chats.kotlinlang.org › t › 23449471 › is-there-a-known-issue-with-debug-breakpoints-in-2024-3-they
Is there a known issue with debug breakpoints in 2024 3 They kotlinlang #intellij
Works here 😉 Which configuration do you run? You didn't mute them, right? Do the breakpoints have that check mark? Please provide slightly more details, so we can start investigation. Thanks! ... Hi Anna. Our project is using: • Kotlin 1.4.31 • JDK 11 • Spring Boot 2.0.6.RELEASE The application is run using · bootRun. I can confirm the breakpoints are being hit correctly using IntelliJ 2024.2.4, but not in 2024.3 or 2024.3.1 Preview
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 6796164198546-Intellij-not-stopping-at-breakpoints
Intellij not stopping at breakpoints – IDEs Support (IntelliJ Platform) | JetBrains
Hi all, I am running a spring boot java application in debug mode in intellij 2022.1.4 community edition. Unfortunately intellij doesn't stop at any breakpoint even if the restful api works prope...
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 203929830-debugging-Kotlin-Intellij-code
debugging Kotlin Intellij code – IDEs Support (IntelliJ Platform) | JetBrains
I've been able to set breakpoints at org.jetbrains.io.Responses.kt However, when I hit a breakpoint, it brings me to Responses.class, not Responses.kt. What's missing? Ditto other Kotlin classes I...
🌐
JetBrains
youtrack.jetbrains.com › issue › KTIJ-9831 › Breakpoints-wont-work-for-Kotlin-testing-with-JUnit
Breakpoints won't work for Kotlin testing with JUnit
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
JetBrains
youtrack.jetbrains.com › issue › KTIJ-9831
Jetbrains
December 27, 2021 - {{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong