Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin annotation processor gives compile time error while using Room with Android Studio 3.0 beta7

I'm compiling Android project using Android Studio 3.0 Beta 7, using Kotlin 1.4-2 and Room Persistence Library 1.0.0-beta1.

This is part of my Gradle file where I'm adding Room dependancies:

implementation "android.arch.persistence.room:runtime:1.0.0-beta1"
kapt "android.arch.persistence.room:compiler:1.0.0-beta1"

While compiling I'm getting following error:

Warning:warning: Supported source version 'RELEASE_7' from annotation processor 'android.arch.persistence.room.RoomProcessor' less than -source '1.8'

After adding stacktrace/debug flags to compile options this is the error I'm getting:

Error:org.jetbrains.kotlin.kapt3.diagnostic.KaptError: Error while annotation processing

10:08:03.727 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 10:08:03.727 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception. 10:08:03.727 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 10:08:03.727 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong: 10:08:03.727 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:kaptDebugKotlin'. 10:08:03.727 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Internal compiler error. See log for more details 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is: 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptDebugKotlin'. 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) 10:08:03.728 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.api.GradleException: Internal compiler error. See log for more details 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:9) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.internal.KaptTask.compile(KaptTask.kt:71) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:731) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:705) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197) 10:08:03.729 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) 10:08:03.730 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111) 10:08:03.730 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92) 10:08:03.730 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 27 more 10:08:03.730 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 10:08:03.730 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 10:08:03.730 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org 10:08:03.730 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 10:08:03.730 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 8s

Clean/rebuild doesn't help. What might be causing this error? The temporary solution seems to be replacing "kapt" with standard "annotationProcessor", rebuild and then building again with "kapt". But after further changes in the project the error keeps popping again.

[EDIT]

My Gradle file (app module):

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.mydomain.myapp"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

androidExtensions {
    experimental = true
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

    // Anko Commons
    implementation "org.jetbrains.anko:anko-commons:$anko_version"

    // Timber logging
    implementation "com.jakewharton.timber:timber:$timber_version"

    // Architecture components - Lifecycle
    implementation "android.arch.lifecycle:extensions:$arch_version"
    kapt "android.arch.lifecycle:compiler:$arch_version"

    // Architecture components - Room ORM
    implementation "android.arch.persistence.room:runtime:$arch_version"
    kapt "android.arch.persistence.room:compiler:$arch_version"

    // Retrofit
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"

    // Picasso
    implementation "com.squareup.picasso:picasso:$picasso_version"
}

Gradle (project module):

buildscript {
    ext.kotlin_version = '1.1.4-2'
    ext.anko_version = '0.10.1'
    ext.timber_version = '4.5.1'
    ext.retrofit_version = '2.3.0'
    ext.picasso_version = '2.5.2'
    ext.constraint_layout_version = '1.0.2'
    ext.support_library_version = '26.1.0'
    ext.arch_version = '1.0.0-beta1'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta7'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}
like image 634
Jan Slominski Avatar asked Oct 06 '17 08:10

Jan Slominski


1 Answers

I'm using kapt plugin and room too, and had a similar error. In my case, I solved it by moving the this line apply plugin: 'kotlin-kapt'from the app build.gradle to the top build.gradle, outside the buildscript{} block, then the error is gone. I found it here

like image 91
Robin Avatar answered Oct 06 '22 11:10

Robin