cashapp / paparazzi

Render your Android screens without a physical device or emulator
https://cashapp.github.io/paparazzi/
Apache License 2.0
2.24k stars 212 forks source link

DataBinding fixing #1305

Closed BrianGardnerAtl closed 4 months ago

BrianGardnerAtl commented 5 months ago

Related to #1016

Two issues I ran into trying to fix this. The first is that attempting to access any data binding from the test results in a class not found for DataBindingMapperImpl. One does get generated but it is not accessible. I found a similar issue related to Roboectric where one of the posts mentioned creating a fake version of the class and adding the actual version via reflection which worked. Here is the example version. I tweaked the implementation since we are unable to query the application package name from the unit test variant.

The second issue is that paparazzi is not loading the processed layout files which is why it's erroring when parsing the layout tag. I found an additional resource directory under build/intermediates/packaged_res/debug that has the processed layouts. Adding this to the projectResourceDirs in the paparazzi plugin allows the correct layout to load. important this has to be the last resource directory. I tried having it first but it was defaulting to the original, unprocessed layout which fails on the layout tag.

jrodbx commented 5 months ago

The second issue is that paparazzi is not loading the processed layout files which is why it's erroring when parsing the layout tag. I found an additional resource directory under build/intermediates/packaged_res/debug that has the processed layouts. Adding this to the projectResourceDirs in the paparazzi plugin allows the correct layout to load.

Yea, this will be partly fixed in https://github.com/cashapp/paparazzi/pull/1136