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
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.
In My Case: Issue resolved
Steps:
<variable
name="viewModel"
type="com.xx.AppViewModel" / >
android:text="@{viewModel.simName}"
binding.viewModel = viewModel
Clean project and recompile.
Add viewModel variable - In XML & Build project.
< variable
name="viewModel"
type="com.xx.AppViewModel" / >
binding.viewModel = viewModel
android:text="@{viewModel.simName}"
-- I hope it will work for you also.
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."
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.
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)
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.