简体   繁体   English

在Android Studio中使用Dokka为Kotlin项目生成Javadoc Kdoc时出错

[英]Error while Generating Javadoc Kdoc for Kotlin Project using Dokka in Android Studio

I am using Dokka plugin to generate documentation for my kotlin project 我正在使用Dokka插件为我的Kotlin项目生成文档

Here is the plugin url https://github.com/Kotlin/dokka 这是插件的URL https://github.com/Kotlin/dokka

I have followed the instructions this is how my Project.gradle looks like 我按照说明进行操作,这就是我的Project.gradle的样子

buildscript {
    ext.kotlin_version = '1.1.51'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.15"
    }
}

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

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

This is how my app/build.gradle looks like 这就是我的app / build.gradle的样子

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

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.kk.testkotlindoc"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dokka {
    outputFormat = 'html'
    outputDirectory = "$buildDir/javadoc"
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

When I execute the below command to generate documentation 当我执行以下命令生成文档时

./gradlew dokka ./gradlew dokka

It initially downloaded the necessary jar files after the process is completed it is giving me the below error 该过程完成后,它最初下载了必要的jar文件,这给了我以下错误

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/KK/AndroidStudioProjects/TestkotlinDoc/app/build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> java.lang.UnsupportedClassVersionError-com/android/build/gradle/AppPlugin

Unsupported major.minor version 52.0 不支持的major.minor版本52.0

But I am unable to identify what is the ISSUE or What am I MISSING HERE 但我无法确定这是什么问题或我在这里丢失了什么

Please help me .. 请帮我 ..

The issue is that you're running Dokka under an older JDK version. 问题是您在较低版本的JDK下运行Dokka。 Dokka requires JDK 8. Please make sure that the environment variable JDK_HOME on your machine points to a JDK 8 installation. Dokka需要JDK8。请确保您计算机上的环境变量JDK_HOME指向JDK 8安装。

您可以在没有Dokka插件的情况下生成Dokka文档。使用GradleMavenPush ,它具有task androidDokka(type: Exec, dependsOn: dokkaInitializer)task coreDokka(type: Exec, dependsOn: dokkaInitializer)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM