我正在尝试生成我的项目的 Doka 文档。在生成时我收到了如上所述的错误。我已经搜索了很多,但无法找到解决方案。我也浏览了this链接。这里说这可能是与匕首相关的问题。我也尝试过这些所有解决方案,但对我不起作用。我在这里发布了我的所有 Gradle 文件以获得更多说明。如果有人遇到这个问题或知道解决方法请发表评论。
项目 Gradle:
buildscript {
ext.kotlin_version = '1.3.20'
ext.dokkaVersion = '0.9.17'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokkaVersion"
classpath "org.jetbrains.kotlin:kotlin-allopen:1.3.20"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用程序 Gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'org.jetbrains.dokka-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xx.xxx.xxx"
minSdkVersion 23
multiDexEnabled true
targetSdkVersion 28
versionCode 1
versionName "1.0.3"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/documentation"
}
dataBinding {
enabled = true
}
signingConfigs {
platform {
storeFile file("../certs/platform.keystore")
storePassword 'xxxxxxxx'
keyAlias 'platform'
keyPassword 'xxxxxxxx'
}
}
buildTypes {
release {
signingConfig signingConfigs.platform
zipAlignEnabled true
}
debug {
debuggable true
signingConfig signingConfigs.platform
zipAlignEnabled true
testCoverageEnabled = true
}
}
androidExtensions {
experimental = true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(':library')
implementation 'com.android.support:design:28.0.0'
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
annotationProcessor 'com.google.dagger:dagger-compiler:2.21'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.21'
implementation 'com.google.dagger:dagger:2.21'
implementation 'com.google.dagger:dagger-android:2.21'
implementation 'com.google.dagger:dagger-android-support:2.21'
kapt 'com.google.dagger:dagger-compiler:2.21'
kapt 'com.google.dagger:dagger-android-processor:2.21'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1-alpha3'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
implementation 'com.android.support.test:rules:1.0.2'
implementation 'com.google.code.findbugs:jsr305:2.0.1'
图书馆梯度:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "kotlin-allopen"
apply from: '../buildsystem/android_commons.gradle'
allOpen {
annotation 'com.xx.xxxx.xxxx.xxxxx'
}
android {
defaultConfig {
versionName "1.0"
buildConfigField "String", "xx", "\"xx\""
}
androidExtensions {
experimental = true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.dagger:dagger:2.21'
implementation 'com.google.dagger:dagger-android:2.21'
implementation 'com.google.dagger:dagger-android-support:2.21'
kapt 'com.google.dagger:dagger-compiler:2.21'
kapt 'com.google.dagger:dagger-android-processor:2.21'
annotationProcessor 'com.google.dagger:dagger-compiler:2.21'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.21'
implementation 'com.google.guava:guava:23.3-android'
}
repositories {
mavenCentral()
}
Error:- 任务:库:kaptReleaseKotlin FAILED 错误:不兼容的类型:NonExistentClass 无法转换为注释 @error.NonExistentClass()
为了帮助您解决为项目生成 Doka 文档的问题,我需要查看相关的 Gradle 文件和您遇到的错误消息。但是,我可以提供一种调试此类问题的通用方法,特别是当它们可能与 Dagger 或任何其他依赖项管理相关时。
检查错误信息:
验证依赖关系:
build.gradle
文件中正确声明所有必要的依赖项。具体来说,检查是否有任何与 Dagger 相关的依赖项。清理并重建项目:
./gradlew clean
./gradlew build
检查 Dagger 配置:
@Module
和 @Component
注释并且它们已正确链接。更新依赖项:
查阅文档和论坛:
以下是您的
build.gradle
文件应如何使用 Dagger 查找项目的示例:
plugins {
id 'java'
id 'kotlin-kapt' // If you are using Kotlin
}
dependencies {
implementation 'com.google.dagger:dagger:2.x'
kapt 'com.google.dagger:dagger-compiler:2.x' // Use annotationProcessor if using Java
// Other dependencies
}
kapt {
correctErrorTypes = true
}
请提供以下信息以获得更具体的帮助:
build.gradle
文件:
build.gradle
文件的内容。build.gradle
文件的内容。错误信息:
匕首配置:
@Module
和 @Component
定义。有了这些信息,我可以提供更有针对性的解决问题的建议。