Android Studio breakpoints in Kotlin code do not work (No executable code found)

Viewed 584

I am working with Android Studio 4.1.2 on macOS to update an existing, Java based Android app. I have now added Kotlin support to the project for the first time. While the Kotline code can be used without any problem, breakpoints within the code do not work:

// Kotlin file Utils.kt
package com.example.myApp

fun doSomething(a: Int, b: Int): Int {
    Log.d("Debug", "I did something...")
    val sum = a + b
    return sum
}

// Some JAVA file
... 
int result = UtilsKt.doSomething(1, 2);

Using breakpoints anywhere in the JAVA code works fine. But when Setting a breakpoint to the val sum = a + b line (or anywhere else in the Kotlin code) a disabled gray circle is shown instead of the usual red dot and hovering with the mouse over it shows the hint

No executable code found at line 42 in class com.example.myApp.UtilKt

enter image description here

Log output shows, that the code actually did run. Also, setting a breakpoint at the Java code that calls the Kotlin code works fine, and stepping into the Kotlin code from there is no problem either.

Cleaning the project, restarting Android Studio, etc. did not help. Any idea how to solve this?

2 Answers

try to click on [Apply code changes] if it didn't work try to [invalidate caches/restart] its an issue in android studio IDE on version 4.1 and aboveenter image description here

try to use breakpoint also where you call method.

Related