I am trying to add Kotlin sources of an AAR in Android Studio 3.3.2. It doesn't work when I select "Choose Sources..." and choose the corresponding source.jar. Android Studio only displays "Attaching..." but nothing happens, as seen in the screenshot below.
Either there is a Bug in Android Studio since I can see a NoSuchElementException in the logs or the source.jar is not as needed. Any hint's to solve the issue are welcome.
Here is the exception:
java.util.NoSuchElementException
at java.util.Collections$EmptyIterator.next(Collections.java:4189)
at org.jetbrains.plugins.gradle.util.GradleAttachSourcesProvider.getSourceFile(GradleAttachSourcesProvider.java:160)
at org.jetbrains.plugins.gradle.util.GradleAttachSourcesProvider.access$100(GradleAttachSourcesProvider.java:59)
at org.jetbrains.plugins.gradle.util.GradleAttachSourcesProvider$1$1.onSuccess(GradleAttachSourcesProvider.java:126)
NOTE: I opened a ticket for Android-Studio -> https://issuetracker.google.com/issues/128352536
Configure kotlin in your project following these steps:-
in build.gradle
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.21'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'
also add
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21"
Clean and Build your project. It worked for me.