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

前端 未结 30 1817
南旧
南旧 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:41

    In my case I have changed globally one variable UserManager to NetWorkManager and everywhere where there were UserManager classes they turned to be NetworkManager.

    Because I'm using Hilt, I had to build the project again.

    I cleaned the Project and Kotlin showed where the errors were.

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

    Interestingly, I was getting this error because I added the description of the Retrofit. Be careful not to confuse the description of Room and Retrofit.

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

    in some cases it may help gradle.properties

    kapt.include.compile.classpath=true
    
    0 讨论(0)
  • 2020-12-12 20:43

    The way to find out what the underlying issue is, is to run the following command :

    ./gradlew assembleDebug --stacktrace
    
    0 讨论(0)
  • 2020-12-12 20:43

    In my case, I used room and one of my databasDao methods has an unused parameter and unfortunately android studio doesn't warn me correctly

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

    I had the same problem. Let me walk you through the example on how I ended up to the problem and the way I resolved it perhaps you can get a bigger picture.

    Before resolving

    @Entity(tableName = "modules")
    data class Module
    (
        @PrimaryKey val id: Int,
        val name: String
    )
    
    @Entity(tableName = "sessions")
    data class Session
    (
        @PrimaryKey(autoGenerate = true) var id: Int,
        @ColumnInfo(name = "module_id") val moduleId: Int,
        @ColumnInfo(name = "start_time") val startTime: String,
        @ColumnInfo(name = "end_time") val endTime: String
    )
    
    data class ModuleSession
    (
        @Embedded val module: Module,
        @Relation(
            parentColumn = "id",
            entityColumn = "module_id"
        )
        val sessions: List<Session>,
        @ColumnInfo(name = "is_updated") val isUpdated: Boolean = false // The problem
    )
    

    In the DAO

    @Transaction
    @Query("SELECT * FROM modules")
    abstract suspend fun getModuleSession(): List<ModuleSession>
    

    The error I got was

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

    So I dug deeper and found the below message

    The columns returned by the query does not have the fields [isUpdated] in com.gmanix.oncampusprototype.Persistence.ModuleSession even though they are annotated as non-null or primitive. Columns returned by the query: [id,name]
        public abstract java.lang.Object getModuleSession(@org.jetbrains.annotations.NotNull()
    

    I removed the field IsUpdated from the POJO ModuleSession and added it to the session table

    After changes

    @Entity(tableName = "sessions")
    data class Session
    (
        @PrimaryKey(autoGenerate = true) var id: Int,
        @ColumnInfo(name = "module_id") val moduleId: Int,
        @ColumnInfo(name = "start_time") val startTime: String,
        @ColumnInfo(name = "end_time") val endTime: String,
        @ColumnInfo(name = "is_updated") val isUpdated: Boolean = false
    )
    
    data class ModuleSession
    (
        @Embedded val module: Module,
        @Relation(
            parentColumn = "id",
            entityColumn = "module_id"
        )
        val sessions: List<Session>
    )
    

    On the other hand crosscheck if there is any field on the SELECT statement that is a suspect causing issues or you can annotate it with @Ignore

    However you can post your code if you're still not comfortable.

    I hope that might help

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