Search code examples
androidandroid-studiomaster-detailandroid-viewbinding

Master/Detail Flow problems with ViewBinding


I was creating an app for some tests, so when Android Studio asks you to select a project template, I choose Master/Detail Flow, at first it starts and executes very well, so I continue to add some Gradle configs I use, one of them is the android.buildFeatures.viewBinding true after synchronized the Gradle, when I try to rebuild the app it fails. This is the error that I get:

Configurations for item_list.xml must agree on the root element's ID.
Missing ID:
- layout-w900dp
@+id/item_list:
- layout

So I tried to fix it but I didn't find anything on the internet, I clean the project, rebuild it, creating a new one without any modification just that one mentioned before, but none of that worked. I noticed there are two files of that file: picture of the two files

These files are created by default, I think that having two files is causing the issue but I just want to know if anyone had resolved this problem before or what solution could you give?

I appreciate any help.

Thanks, GiusNiyyel.


Solution

  • This error comes because the template generates two layouts with different root views (linear layout and recyclerview) for the list.xml, and list.xml (w900dp)

    wrap the recyclerview with a LinearLayout and you are good to go