Architecture-components-samples: Room does not work with data binding

Created on 15 May 2018  路  11Comments  路  Source: android/architecture-components-samples

I have create one project that uses a data binding library, but whenever i use room library in my project i have found an error like follow.

error: package com.example.project.databinding does not exist
import com.example.project.databinding.ActivityTutorialScreenBinding;
                                      ^

error: cannot find symbol
private ActivityTutorialScreenBinding binding;
        ^
symbol:   class ActivityTutorialScreenBinding
location: class IntroducationScreen

Please help me out if any one found solution of this issue.
Thanks

Most helpful comment

i have same error

All 11 comments

i have same error

Hi, i fix it following this Google project AND update Android Studio to Canary16

Having the same issue with Room and DataBinding 馃槩

Hi, i solved the issue by creating a new module for room

Hi, I solve this problem just fixing SQL query. The problem as that userId was incorrect,
@Query("SELECT * FROM User WHERE userId = :userId") the name of the row in the table was user_id. Just fixing that and everything works fine.

I had the same issue. After spending hours on this, I finally fixed the error by replacing LiveData<ArrayList<MovieFavEntity>> to LiveData<List<MovieFavEntity>> . Just check the return type and queries of the different method in the Dao.

I guess this problem is related to kapt or annotationProcessor itself not room.
When the build fails, the databinding fails to generate these files too and Android Studio throws all errors to your face.

So you might need to go to the first error in the log or temporarily change kapt to annotationProcessor and rebuild to get clear error message.

Hello Team, I am facing the same issue which is raised. Can you please quickly look into that and fix this bug as soon as possible. as it impacts a lot for large scale project.

After enabling data binding
"dataBinding {
enabled = true
}"
I get
"[kapt] An exception occurred: java.lang.ExceptionInInitializerError"

It is working fine. you just need to use the latest versions of kotlin and room. I was also facing the issues earlier when I was also using dagger but after that when I switched to KOIN and used all latest versions it is working fine.

This doesn't seem to be an issue with the samples. You can file an issue against Room on the issue tracker if you're still having an issue.

Was this page helpful?
0 / 5 - 0 ratings