Can't debug my Android library if the class was created with Kotlin

Viewed 1346

I created an Android library that was originally coded with Java and it outputs an .aar file that I use in some of my projects.

When I include this lib in a project (an Android project created with Kotlin) and I decide to debug the code in this project, when the debugger reaches a line containing a library's class, it successfully steps into the class and I can see the source code of the class while I'm debugging it. I can continue the debug line by line inside the lib's class and everything works as expected.

However, I recently decided to convert this library to Kotlin but now, when the debugger reaches one of the lib's class and I step into the class to continue debugging there, I can no longer see the entire source code. I can only see the method signatures, but without the method definitions. I see only things like:

public class ClassA {
    public fun function1(): kotlin.Unit

    public fun function2(): kotlin.Unit

    public fun function3(): kotlin.Unit
}

I didn't do any else in the library's project settings. I simply converted the files from .java to .kt.

Here are some things that I tried so far to solve this problem:

  • I confirmed that I included Kotlin's standard lib in the dependencies list of the build.gradle file in the library.
  • I disabled ProGuard (it has never been a problem, but I removed it just in case).
  • I disabled code minification (it has never been a problem too, but at this point I'm willing to try anything).

Anyone has any idea why this is happening?

1 Answers

While debugging when it prompt "Choose Sources", Click on that option

enter image description here

and select the "main" folder of the library module from your local codebase of the library

enter image description here

Now try to debug (by choosing 'step into' option etc), the debugger should able to get the source code.

Related