Android Kotlin - Room Local Storage, build error "A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution"

10,201

Solution 1

Android Studio's UI was just hiding the error...

when the error occurred, it highlighted the item in the list view, and showed an unhelpful message in the terminal view. bad bad

to find the real error, select the root item in the list view so that Android Studio would display the whole build output in the terminal view, then scroll to find error. good good

Solution 2

The error is show by the kapt in your project, and to show full error message you will have to add these to your gradle.properties file.

kapt.use.worker.api=false
kapt.incremental.apt=false

After that run your app again, and try to read from the detailed error.

kapt error image

Solution 3

Verify your DAO, make sure everything is where it is supposed to be. 4/5 when I get this error, I find out I miswrote/forgot something somewhere with the dao

Solution 4

If you have Hilt in your project with Kotlin, make sure you have annotated your module class with:

@Module
@InstallIn(SingletonComponent::class)

Solution 5

I was getting the same error, when i was trying to retrieve all the columns from db with return type of LiveData array list(Dao file), eg: return type was -

LiveData<ArrayList<Book>>

And when i change ArrayList to list like this: LiveData<List<Book>>

Although i'm not sure about the cause or reason for the error, the above chnages worked for me

also,

If you are using coroutines, check the room dependency for room-ktx

Share:
10,201
Bong Channarith
Author by

Bong Channarith

Updated on July 29, 2022

Comments

  • Bong Channarith
    Bong Channarith almost 2 years

    [Using Gradle 4.0.0], I try to implement local storage by room in Android Kotlin in Andriod Studio 4. When I try to build project, i meet an error in build console

    A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

    Image:

    enter image description here

    Gradle:

    apply plugin: 'kotlin-kapt'
    
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version" 
    

    Please kindly help to show the solution for me

  • Ravindra Kushwaha
    Ravindra Kushwaha almost 3 years
    Can you please help me on it..I am using the hilt with my java andorid and getting this following exception java.lang.reflect.InvocationTargetException (no error message) ..Please help me
  • Custadian
    Custadian over 2 years
    Thanks @Eric for the right approach to understand the core issue.