当前位置: 首页 > 知识库问答 >
问题:

任务“:app:kaptDebugKotlin”的执行失败。“>执行组织时出错。喷气式飞机。科特林。格拉德尔。内部的KaptExecution公司

齐威
2023-03-14

在Android Studio中构建项目时,我遇到了这个信息不太丰富的错误。我尝试了stackoverflow的所有方法,但都无效。

任务“:app:kaptDebugKotlin”的执行失败。

执行组织时出错。喷气式飞机。科特林。格拉德尔。内部的KaptExecution java。朗,反思一下。InvocationTargetException(无错误消息)

我的应用程序gradle:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-parcelize'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'




}



android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {

        configurations.all {
            resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
        }

        applicationId "com.nenad.favrecipes"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        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'
    }

    android {
        buildFeatures {
            dataBinding true
        }

    }


    dependencies {

        implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" //1.5.21
        implementation 'androidx.core:core-ktx:1.6.0'
        implementation 'androidx.appcompat:appcompat:1.3.0'
        implementation 'com.google.android.material:material:1.4.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        testImplementation 'junit:junit:4.+'
        androidTestImplementation 'androidx.test.ext:junit:1.1.3'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

        implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
        implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'


        implementation 'com.squareup.retrofit2:retrofit:2.9.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
        implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'

        implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"

        // RxJava
        implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
        implementation 'io.reactivex.rxjava3:rxjava:3.0.0'

        implementation "com.squareup.retrofit2:retrofit:2.9.0"
        implementation "com.squareup.retrofit2:converter-scalars:2.9.0"
        implementation "com.squareup.retrofit2:converter-moshi:2.9.0"

        implementation "com.squareup.okhttp3:okhttp:4.9.1"
        implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
        implementation "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"

        implementation 'androidx.multidex:multidex:2.0.1'

        implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'

        //shimmering RV
        implementation 'com.facebook.shimmer:shimmer:0.5.0'
        implementation 'com.todkars:shimmer-recyclerview:0.4.1'

        implementation 'com.google.code.gson:gson:2.8.7'

        implementation 'com.google.dagger:hilt-android:2.40.5'
        kapt 'com.google.dagger:hilt-compiler:2.40.5'

        implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

        // DataStore
        implementation "androidx.datastore:datastore-preferences:1.0.0"
        implementation "androidx.datastore:datastore:1.0.0"

        implementation("androidx.fragment:fragment-ktx:1.3.0")

        def room_version = '2.3.0'
        implementation "androidx.room:room-runtime:$room_version"
        kapt "androidx.room:room-compiler:$room_version"
    }
    kapt {
        correctErrorTypes true
    }
}

我的项目gradle:

buildscript {
    ext.kotlin_version = "1.3.72" 
    repositories {
        google()
        jcenter()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3' //4.1.3
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
plugins {

    id "org.jetbrains.kotlin.android" version "1.4.20" apply false
}

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

}

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

共有1个答案

范玄裳
2023-03-14

您的应用程序级模块应如下所示:

建筑gradle(:应用程序)

buildscript {
repositories {
    google()
    mavenCentral()

}
dependencies {
    classpath 'com.android.tools.build:gradle:4.1.3' //4.1.3
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
    classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
 }
}
 task clean(type: Delete) {
    delete rootProject.buildDir
}

另外,另一个gradle文件应该如下所示:

建筑gradle(:应用程序)

plugins {
   id 'com.android.application'
   id 'kotlin-android'
   id 'kotlin-parcelize'
   id 'kotlin-kapt'
   id 'dagger.hilt.android.plugin'
}


android {
   compileSdkVersion 30
   buildToolsVersion "30.0.3"

   defaultConfig {

    configurations.all {
        resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
    }

    applicationId "com.nenad.favrecipes"
    minSdkVersion 23
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

    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'
}

buildFeatures {
    dataBinding true
}


dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.21" //1.5.21
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'


    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'

    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"

    // RxJava
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
    implementation 'io.reactivex.rxjava3:rxjava:3.0.0'

    implementation "com.squareup.retrofit2:retrofit:2.9.0"
    implementation "com.squareup.retrofit2:converter-scalars:2.9.0"
    implementation "com.squareup.retrofit2:converter-moshi:2.9.0"

    implementation "com.squareup.okhttp3:okhttp:4.9.1"
    implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
    implementation "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"

    implementation 'androidx.multidex:multidex:2.0.1'

    implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'

    //shimmering RV
    implementation 'com.facebook.shimmer:shimmer:0.5.0'
    implementation 'com.todkars:shimmer-recyclerview:0.4.1'

    implementation 'com.google.code.gson:gson:2.8.7'

    implementation 'com.google.dagger:hilt-android:2.40.5'
    kapt 'com.google.dagger:hilt-compiler:2.40.5'

    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

    // DataStore
    implementation "androidx.datastore:datastore-preferences:1.0.0"
    implementation "androidx.datastore:datastore:1.0.0"

    implementation("androidx.fragment:fragment-ktx:1.3.0")

    def room_version = '2.3.0'
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
}
kapt {
    correctErrorTypes true
  }
}
 类似资料:
  • 我正在尝试在eclipse中设置我的第一个gradle项目,但我在构建gradle时遇到了问题。我已经从spring.io复制了build.gradle,但它仍然无法正常构建。我得到任务执行失败:编译Java。我的build.gradle文件如下所示

  • 我刚开始使用Kotlin,并尝试使用Dagger2进行设置,我见过一些示例,但它们似乎都不适合我。 我一直收到这个 错误:任务执行失败:应用程序:kaptDebugKotlin。 内部编译器错误。有关更多详细信息,请参阅日志 我有我的身材。gradle(模块:应用程序)

  • 添加刀柄依赖项: Build.gradle(项目) 建筑gradle(应用程序) 我还有一个全局应用类: MyApplication.kt 在我的清单中: 显示xml 现在,我创建一个模块 NetworkModule.kt 我运行代码时出错: **任务“:app:kaptDebugKotlin”的执行失败。 执行org时发生故障。喷气式飞机。科特林。格雷德尔。内部的KaptExecution ja

  • 失败:构建失败,有一个异常。 > 其中:脚本'C:\src\flatter\packages\flatter\u tools\gradle\flatter。格雷德尔热线:780 出错的原因:任务执行失败:app: compileFlutterBuildDebug。 JAVAlang.NullPointerException(无错误消息) > 获得更多帮助https://help.gradle.or

  • 我刚刚从金丝雀频道将Android studio 2.2.2升级到2.3。下载完成并应用路径文件后,android studio将重新启动。但在重新启动android studio后,我发现以下对话框错误: 无法加载项目:com。intellij。石斑鱼类。插件。PluginManager$startupbortedexception:com。intellij。诊断的。PluginExceptio

  • 错误:任务执行失败 ': app:使用合并Java Res For Debug转换资源'。 com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException: APK META-INF/LICENSE File1中复制的重复文件: C:\用户Jithin-P