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

前端 未结 30 1795
南旧
南旧 2020-12-12 20:01

All of sudden I start getting this error, and I am not getting idea why if anyone just let me know where this error is, will be enough helpful. As much I am able to get is t

相关标签:
30条回答
  • 2020-12-12 20:25

    After a lot of pain, I decided to try annotationProcessor instead of kapt hoping it may at least show an error message or anything that can help me locate the source. But fortunately (or unfortunately; because of the wasted time), it was built successfully without any errors. It's mostly a bug in kapt itself. So, try this solution and it may help.

    0 讨论(0)
  • 2020-12-12 20:25

    In My Case: Issue resolved

    Steps:

    1. Remove viewModel variable - In XML.
    <variable
        name="viewModel"
        type="com.xx.AppViewModel" / >
    
    1. Removed all viewModel binding references - In XML.
    android:text="@{viewModel.simName}"
    
    1. Removed viewModel instance reference to the binding mapping - In Activity
    binding.viewModel = viewModel
    
    1. Clean project and recompile.

    2. Add viewModel variable - In XML & Build project.

    < variable
        name="viewModel"
        type="com.xx.AppViewModel" / >
    
    1. Add viewModel instance reference to the binding mapping - In Activity & Build project
    binding.viewModel = viewModel
    
    1. Add all viewModel binding references - In XML & Build project..
        android:text="@{viewModel.simName}"
    
    1. It will work now.

    -- I hope it will work for you also.

    0 讨论(0)
  • 2020-12-12 20:28

    I had the same error for a while then I started checking the other packages I came to know that I've made a typo mistake in my database code. So, "Go through your database and other activity class files u may find some mistakes there."

    0 讨论(0)
  • 2020-12-12 20:32

    Nothing worked I tried everything and finally found a small mistake which was creating a big problem.

    Go back to each newly created file for database and check for code line by line of each file carefully.

    Check Database class and check if Dao is declared as for example,

    abstract val commentDatabaseDao: CommentDatabaseDao
    

    declare as val not var, this was in my case and finally for this resolved.

    0 讨论(0)
  • 2020-12-12 20:34

    This problem also happens if you installed new kotlin plugin (1.4.20-release-Studio4.1-1) and have dagger (kapt 'com.google.dagger:dagger-compiler:2.30'). In such a case one solution might be replacing deprecated plugin: 'kotlin-android-extensions' with view binding (https://developer.android.com/topic/libraries/view-binding)

    0 讨论(0)
  • 2020-12-12 20:35

    For me, the issue was with having 2 primary keys defined on the model.

    // before    
    @field:ColumnInfo(name = "id") @field:PrimaryKey(autoGenerate = true) var id: Long = 0,
    @field:ColumnInfo(name = "name") @field:PrimaryKey var name: String,
        
    //after
    @field:ColumnInfo(name = "id") @field:PrimaryKey(autoGenerate = true) var id: Long = 0,
    @field:ColumnInfo(name = "name") @field:NotNull var name: String,
    

    I had to rebuild the project and change the Dao class a little bit to trigger the message about the issue.

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