Azay Gupta
Azay Gupta

Reputation: 311

Not able to access source code of AAR file build in Kotlin

I build a module in Kotlin, then import in my project. I put minifyEnabled false in module's build.gradle file. But unable to see the source code or unable to put a breakpoint.

It's working with Java but not with Kotlin.

Upvotes: 6

Views: 1658

Answers (2)

king meng
king meng

Reputation: 11

publishing {
    singleVariant("release") {
        withSourcesJar()
        withJavadocJar()
    }
}

add this in android{ }

Upvotes: 0

rrs
rrs

Reputation: 11

Maybe it's still helpful for someone.

To see the Kotlin sources you'll need to have a sources.jar, besides the .aar file. To do that you can add the following in the .gradle file where you make your maven publishing

task androidSourcesJar(type: Jar) {
    archiveClassifier = 'sources'
    from (android.sourceSets.main.java.sourceFiles, android.sourceSets.main.kotlin.sourceFiles)
}

artifacts {
    archives androidSourcesJar
}

This will generate a sources.jar file in your <<library name>>/build/libs.

Then you can include this jar file along with your .aar library file. It seems like Android Studio knows how to download the sources for .jar automatically, but if not, you can download them and then use the Choose sources option in the toolbar above the code.

Upvotes: 1

Related Questions