Gradle 问题:任务 ':app:kaptDebugKotlin' 执行失败

时间:2021-02-01 14:12:00

标签: android android-studio build.gradle objectbox

我刚刚将 objectbox 添加为我的项目的依赖项。 我必须遵循的最后一步是添加这两行:

id 'kotlin-kapt' // Required for annotation processing.
id 'io.objectbox' // Apply last.

在插件部分。我能够重建该项目。 但是,现在当我尝试运行该项目时,出现以下错误:

Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
   > java.lang.reflect.InvocationTargetException (no error message)

这就是我的 build.gradle(Project) 的样子

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.4.21"
    ext.objectboxVersion = '2.8.1'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files    

    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://maven.google.com" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
This is what my build.gradle (Module) looks like :
plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt' // Required for annotation processing.
    id 'io.objectbox' // Apply last.
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.weatherapp"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.recyclerview:recyclerview:1.2.0-beta01'
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.ncapdevi:frag-nav:3.2.0'
    implementation 'com.techyourchance:dialoghelper:0.9.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.8.1'
    implementation 'com.google.android.gms:play-services-location:17.1.0'
    implementation 'net.danlew:android.joda:2.10.9.1'
    testImplementation 'org.mockito:mockito-core:3.3.3'
}

我尝试对依赖项进行其他更改以改用 kapt,但仍然遇到相同的错误

0 个答案:

没有答案