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
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.
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.
in some cases it may help gradle.properties
kapt.include.compile.classpath=true
The way to find out what the underlying issue is, is to run the following command :
./gradlew assembleDebug --stacktrace
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
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