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

leggo picture leggo · Oct 20, 2017 · Viewed 30.2k times · Source

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()
}

Answer

Łukasz Kobyliński picture Łukasz Kobyliński · Oct 20, 2017

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.