Sunday, December 9, 2018

"error: cannot find symbol class DataBindingComponent" happens when wrong return type added to Room insert method

I want to share with you an instructive story, when I use Room Persistence Library and Data Binding...

Environment:
- Windows 7 64bit
- Java 8
- Android Studio 3.2



I tried everything to figure out what was the problem. First, I thought maybe my layout file was the problem,... but not.

Then after about 1 hour I find that one of my DAO's save() method returns with an Integer, but my update() is void.  What do you think, what is the problem with the following code?


@Insert
@Transaction
Integer save(MenuItemEntity entity);

Yes, the Integer. Because an insert method always returns with a long, which is the new rowId! Or it can be a void:

@Insert
@Transaction
void save(MenuItemEntity entity);

And... magic, the project builded successfully:

So never forget: R T F M !

Configure and use VSCode for Java web development

Embarking on Java web development often starts with choosing the right tools that streamline the coding process while enhancing productivity...