Can't get dokka to generate kotlin docs on gradle/android project

梦想与她 提交于 2019-12-05 08:34:24

Try Kotlin 1.0.0 release, with latest Dokka 0.9.7. You have a mismatch there. The Kotlin plugin for Gradle and the Dokka versions must be compatible. If you continue to have a conflict, it could be that you have another plugin conflicting with those.

Dokka 0.9.8 or newer no longer will conflict with the Kotlin compiler version if different. It now contains what it needs embedded as shaded dependencies to avoid conflicts.

[UPDATE] This is reported as fixed with https://github.com/Kotlin/dokka/pull/64.


The problem is that the current version of dokka is unable to pick up the sourceSets defined within the android block of the build.gradle file.

To work around this until it is fixed (I'll create an issue on the dokka Github repository), you can duplicate the sourceSets outside of the android block so that dokka can figure it out.

android {
  ...

  sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
    test.java.srcDirs += 'src/test/kotlin'
  }
}

sourceSets {
  main.java.srcDirs += 'src/main/kotlin'
  test.java.srcDirs += 'src/test/kotlin
}

I had the same problem and this fixed it for me.

The dokka documentation deals with Android separately:

If you are using Android there is a separate gradle plugin. Just make sure you apply the plugin after com.android.library and kotlin-android.

Try using classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${versions.dokka}" as a dependency and adding apply plugin: 'org.jetbrains.dokka-android' to the end of your plugin list, removing apply plugin: 'org.jetbrains.dokka' from the beginning.

EDIT: This should be fixed, as noted in the comment below.

You can generate Dokka documentatiton without Dokka plugin... Use GradleMavenPush, it has task androidDokka(type: Exec, dependsOn: dokkaInitializer) and task coreDokka(type: Exec, dependsOn: dokkaInitializer)

apply from: 'https://raw.github.com/Vorlonsoft/GradleMavenPush/master/maven-push.gradle'

Don't forgot to set JAVADOC_BY_DOKKA = true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!