Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Execution failed for task ':app:kaptDebugKotlin'

I'm new to using Kotlin and trying to set it up with Dagger2, I've seen some few examples but none of them seem to work for me.

I keep getting this

Error:Execution failed for task ':app:kaptDebugKotlin'.

Internal compiler error. See log for more details

I have my build.gradle (Module: app)

apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-android-extensions'  android {     compileSdkVersion 25     buildToolsVersion "25.0.0"     defaultConfig {         applicationId "com.exampleapp"         minSdkVersion 14         targetSdkVersion 25         versionCode 1         versionName "1.0"         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"     }     buildTypes {         release {             minifyEnabled false             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'         }     }     kapt {         generateStubs = true     }     dexOptions {         javaMaxHeapSize "2048M"     } }  ext {     supportLibVer = '25.0.0'     daggerVer = '2.8' }  dependencies {     compile fileTree(dir: 'libs', include: ['*.jar'])      // Support lib     compile "com.android.support:appcompat-v7:${supportLibVer}"      kapt "com.google.dagger:dagger-compiler:${daggerVer}"     compile "com.google.dagger:dagger:${daggerVer}"     provided "javax.annotation:jsr250-api:${javaxVer}"      compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"   } repositories {     mavenCentral() } 
like image 753
leggo Avatar asked Oct 20 '17 13:10

leggo


2 Answers

Run your application with ./gradlew clean build command to see what's exactly wrong with your code. Just paste it into the Terminal in Android Studio.

like image 126
Łukasz Kobyliński Avatar answered Sep 23 '22 08:09

Łukasz Kobyliński


If you are using the Room database and getting a KAPT error, just check your

  1. Database declarations
  2. Data Access Object declarations
  3. Data class fields

It's a problem arising due to improper usage of annotations of Room. For more information use your build logs.

You can see here in this picture before expanding the error log, I can see the annotation missing error.

like image 29
Willey Hute Avatar answered Sep 21 '22 08:09

Willey Hute