Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dokka plugin not found in Android studio 3

I'm trying to use the dokka plugin in my Kotlin project, but I'm getting the following message:

Error:(7, 0) Plugin with id 'org.jetbrains.dokka' not found.

I'm using Android Studio version 3.0.

Thanks in advance.

like image 570
Melchior Avatar asked Nov 07 '17 21:11

Melchior


2 Answers

Using Dokka with Kotlin in Android Studio for the first time

#1. Settings

##1.1 Settings in build.gradle(Project)

buildscript {
    ext {
        version_dokka = "0.10.0"
        version_gradle = "3.5.2"
        version_kotlin = "1.3.41"
        ...
    }
    dependencies {
        classpath "com.android.tools.build:gradle:$version_gradle"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$version_kotlin"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:${version_dokka}"
        ...
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

##1.2 Settings in build.gradle(Module:app)

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    ...
    // Dokka used for auto-generation documentation
    dokka {
        outputFormat = 'html'
        //outputDirectory = "$buildDir/dokka"

        configuration {
            // Do not output deprecated members
            skipDeprecated = true

            // Emit warnings about not documented members.
            reportUndocumented = true

            // Do not create index pages for empty packages
            skipEmptyPackages = true
        }
    }
}

// workaround: create DocsByDokka
task DocsByDokka (type: org.jetbrains.dokka.gradle.DokkaTask) {
    outputFormat = "html"
    outputDirectory = "$buildDir/dokka"
}

Don't forget to sync

#2. Building the docs

##2.1 Your code should contain comments. Take a look at the following link, in order to get more details: https://kotlinlang.org/docs/reference/kotlin-doc.html

##2.2 Go to the Gradle-Window in Android Studio I have to click on "Gradle" at the right top corner in Android Studio 3 After clicking on "Gradle" a window opens. --> MyProject --> app --> Tasks --> DocsByDokka

enter image description here

Gradle-Window in Android Studio

##2.3 Generate Docs Double Click on DocsByDokka in the Gradle-Window.

#3. Find the docs ##3.1 Go to your Project-Folder Select the Project and not the Android view. I find this by default at the left corner of Android Studio. --> MyProject --> app --> build --> dokka --> app There you are going to find index.html. Right-click and select "Open in Browser".

like image 104
mitch mkrtchian Avatar answered Oct 11 '22 00:10

mitch mkrtchian


So, when I ran into the issue, example I was reading, did not specify exactly where to put dokka dependencies. Once I figured those out, the project compiled and build:

build.gradle (Project level file):

buildscript {
    ext.kotlin_version = '1.2.51'
    ext.kotlin_version = '1.2.30'
    ext.dokka_version = '0.9.17'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

build.gradle (Module level file):

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.dokka-android'

android {
    compileSdkVersion 27

    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
...

    dokka {
        outputFormat = 'javadoc'
        outputDirectory = "$buildDir/javadoc"
    }
}
like image 3
mike.tihonchik Avatar answered Oct 11 '22 01:10

mike.tihonchik