Debugging Timers on Android


#1

We have written an Android Service that concurrently executes code repeatedly using kotlin timers.
Sadly, breakpoints in the (crossinlined) lambdas of the timers are ignored, although the code is obviously being executed (we can see its output in the console).

class BasisService : Service() {
    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        runAsync {
            println("test") // breakpoint at this position works
        }
        kotlin.concurrent.timer("Repeating println",period=1.sec) {
            println("rtest") // breakpoint at this position is ignored. message is: No executable code found at line ...
        }
}

And please notice: We have already ruled out other typical reasons for the error-message “no executable code found” like old versions of the app on the device and such. We have really wasted a lot of time on finding a reason for this problem on different computers and different Android devices.


#2

I have reported KT-17295, it’s not specific to Android.