簡體   English   中英

在Android Studio中使用Dokka為Kotlin項目生成Javadoc Kdoc時出錯

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

我正在使用Dokka插件為我的Kotlin項目生成文檔

這是插件的URL https://github.com/Kotlin/dokka

我按照說明進行操作,這就是我的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
}

這就是我的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'
}

當我執行以下命令生成文檔時

./gradlew dokka

該過程完成后,它最初下載了必要的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

不支持的major.minor版本52.0

但我無法確定這是什么問題或我在這里丟失了什么

請幫我 ..

問題是您在較低版本的JDK下運行Dokka。 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