How to attach the Kotlin library sources?


I seem to have lost the source attachment with the latest update (I can no longer go to a source inside the Kotlin libraries). When I click on the "Attach sources" hyperlink and I get presented with a dialog, which path should I put there? It's not quite clear to me from the folder structure of the github project...



It's easy: you need to put the path to root folder which contains sources. If this folder is under jar, there's no problem: you can expand jars as usual folders in this dialog.

If you lost sources of Kotlin runtime, try removing kotlin-runtime.jar and reinstalling it using editor warning bar. If this doesn’t help, maybe there is a bug in navigation to sources.   


Android Studio 1.4 beta 2 (also 1.3, and probably any other) Kotlin plugin 1235, kotlin version 1230

If i do as suggested, i get infinite Attaching… in toolbar

Also my library jar have jar with sources, and it’s not resolved either.


I can’t debug code in dependent libraries, its frustrating


Hi Dmitriy,

There is an issue in your tracker ( We are investigating where the problem is.


Issue is only about Choose Sources dialog(basically an IDE problem?) But i also can't get sources in normal case, with dependency via gradle.


Could you attach your build.gradle file to the issue, please? How did you configure sources for your library? Is the library written in Kotlin?


Natalia, i found my problem:

build.gradle in kotlin library project has setting:

task sourceJar(type: Jar) {
    from sourceSets.main.allJava

i got an empty sources jar

is it possible that on older versions of kotlin it works correctly? because i tested it before and it worked Oo
I assume that after m12 manipulations with possibility to place java and kotlin files in same folder it was broken.

now i changed it to:

task sourcetypepepe: Jar) {
    from sourceSets.main.allSources

and it works now.


However i can't fix android-library source attaching (aar)

for example i can’t see sources for
and also for my own android libraries.

task androidSourcesJar(type: Jar) {
    classifier = 'sources'

sources are generated and i can see them under .jar, but can't get it to work in AS


I fail to generate sources using your last hint above.
The sources.jar gets genrated, but it contains only empty directories and no kt files.

Is there some documentation somewhere on how one would go about creating a kotlin (android) library along with a sources .jar?

I also use my kotlin library in a java based project and I wonder - what should I do to document it, for the users to see


Hey dude, is there any walkaroud to attach kotlin sources code in android project right now?