I keep encountering the same errors related to Kotlin's annotation processing (KAPT) everytime i try to build the source.
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> A failure occurred while executing .jetbrains.kotlinpilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Internal compiler error. See log for more details
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at .
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsReleaseKotlin'.
> A failure occurred while executing .jetbrains.kotlinpilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Internal compiler error. See log for more details
My build gradle (app level)
plugins {
id 'com.android.application'
id '.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
}
android {
namespace 'com.verihome.inspector'
compileSdk 34
defaultConfig {
applicationId "com.verihome.inspector"
minSdk 24
targetSdk 34
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'
}
buildFeatures {
viewBinding true
dataBinding true
}
}
dependencies {
// Core Android dependencies
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
// Architecture Components
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation 'androidx.fragment:fragment-ktx:1.6.2'
implementation 'androidx.activity:activity-ktx:1.8.2'
// Navigation Component
def nav_version = "2.7.6"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
// Retrofit for API calls
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
// OkHttp for networking
def okhttp_version = "4.12.0"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
// Coroutines for asynchronous code
def coroutines_version = "1.7.3"
implementation ".jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation ".jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
// Glide for image loading
def glide_version = "4.16.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
// Testing
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
my build gradle (project level)
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.7.6"
}
}
plugins {
id 'com.android.application' version '8.2.1' apply false
id 'com.android.library' version '8.2.1' apply false
id '.jetbrains.kotlin.android' version '1.9.22' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I am using room and kotlin. I cant see what im doing wrong here. Been banging my head on this for 2 days. Any help would be very much appreciated. Thanks.
I keep encountering the same errors related to Kotlin's annotation processing (KAPT) everytime i try to build the source.
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> A failure occurred while executing .jetbrains.kotlinpilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Internal compiler error. See log for more details
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle..
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsReleaseKotlin'.
> A failure occurred while executing .jetbrains.kotlinpilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Internal compiler error. See log for more details
My build gradle (app level)
plugins {
id 'com.android.application'
id '.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
}
android {
namespace 'com.verihome.inspector'
compileSdk 34
defaultConfig {
applicationId "com.verihome.inspector"
minSdk 24
targetSdk 34
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'
}
buildFeatures {
viewBinding true
dataBinding true
}
}
dependencies {
// Core Android dependencies
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
// Architecture Components
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation 'androidx.fragment:fragment-ktx:1.6.2'
implementation 'androidx.activity:activity-ktx:1.8.2'
// Navigation Component
def nav_version = "2.7.6"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
// Retrofit for API calls
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
// OkHttp for networking
def okhttp_version = "4.12.0"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
// Coroutines for asynchronous code
def coroutines_version = "1.7.3"
implementation ".jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation ".jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
// Glide for image loading
def glide_version = "4.16.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
// Testing
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
my build gradle (project level)
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.7.6"
}
}
plugins {
id 'com.android.application' version '8.2.1' apply false
id 'com.android.library' version '8.2.1' apply false
id '.jetbrains.kotlin.android' version '1.9.22' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I am using room and kotlin. I cant see what im doing wrong here. Been banging my head on this for 2 days. Any help would be very much appreciated. Thanks.
Share Improve this question asked Mar 17 at 18:07 Lawless LeopardLawless Leopard 672 silver badges11 bronze badges1 Answer
Reset to default 0The KAPT errors you're encountering are often due to dependency version mismatches, incompatible plugins, or misconfigured annotation processors
For example, if you’re using Kotlin 1.9.22 with Room, make sure you’re on a Room version that supports that Kotlin release.
Also, I would suggest running the following command to analyze the actual version, as sometimes a dependency can secretly update another dependency:
./gradlew dependencies > dependencies.txt