After adding Kapt plugin - A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

后端 未结 7 2131
遥遥无期
遥遥无期 2020-12-21 00:07

First of all,

I\'m pretty much aware that a lot of questions on this error had been posted already here, and none of them seems to be having a proper solution especia

相关标签:
7条回答
  • 2020-12-21 00:18

    Replacing

    kapt "android.arch.persistence.room:compiler:$room_version"
    

    by

    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
    

    might fix it as well.

    0 讨论(0)
  • 2020-12-21 00:18

    After a week's struggle, I finally found the issue.

    I added the kotlin-kapt plugin for realm.

    And I had a folder named interface itself to hold some interfaces.

    I implemented one of the interfaces from the interface folder in MainActivity.

    Now the import for the interface was something like this,

    import com.android.app.java.interface.Listener

    Where, the keyword interface confused the annotation processor, hence caused error while generating stub.

    I renamed the folder (from interface to intrface).

    That solved the error.

    This is a very simple mistake that cost me a week.

    Anyway, found the issue. Yay!

    0 讨论(0)
  • 2020-12-21 00:23

    For me when I rewrited dao class it solved problem

    0 讨论(0)
  • 2020-12-21 00:25

    I put a @Delete annotation on a method with Long parameters :

    @Delete
    fun deleteRelationShip(userId: Long, friendId: Long)
    

    --debug build can be of help i most cases. In this case it said that a long couldn't be convert in Element

    Then it becomes

    @Delete
    fun deleteRelationShip(relationShip: RelationShip)
    
    0 讨论(0)
  • 2020-12-21 00:30

    I had the same problem. I forgot to add @Dao annotation in my room database

    0 讨论(0)
  • 2020-12-21 00:34

    I had a similar issue and spent forever trying to find the issue. I found another thread that you can run Analyze -> Inspect Code to find the issue, but this didn't work for me and showed nothing, but apparently others had success with this.

    My issue ended up being with my database (I was using Room) and the fix was simply a matter of removing a "suspend" I had on an insert function in my DAO..

    I found this issue by looking in the java generated code folder. Look at all your database files that are generated with "_Impl". The error was highlighted in red and then I could deduce from here what was going wrong (although I don't know why Android Studio couldn't just show me that error in the build output :/ )

    Best of luck though! Those kapt errors are the worst

    0 讨论(0)
提交回复
热议问题