Android view binding between modules
If I am correct you have this kind of structure
project
| -- app
| -- module1 [ contains layout_one.xml and layout_fragment.xml]
| -- module2 [ contains layout_two.xml]
layout_fragment.xml
will include both layout_one.xml
and layout_two.xml
Now in order to make this work, all you need to do is go to module1 build.gradle
file and add this dependency
implementation project(":module2")
Note your app will be aware of module1 and module2 files but module1 and module2 files will not be aware of both of there existence. So by specifying this dependency we make module1 to depend on module2
and also make sure in each module viewBinding is enabled
I had the exact same issue.Today, after a week I worked again on this issue and I had to invalidate cache and restart in Android Studio because ViewBinding
classes were always highlighted red with "Can't resolve" but building and running was successful.I did a clean build before and then invalidate cache and restart.
After that everything worked as aspected.
I hope this helps in your case as well.
The problem for me was that Windows 10 restricted the download function in Android Studio and did not allow it to download. Maybe you should go through the process of building an Android Studio trust in Windows 10.