问题
I have a multi module project which is structured something like this. Here is the code to play around with this error: https://github.com/ajitsing/MultiModuleAndroid
Root
|- App Module (Application, Data binding enabled)
|- Lib Module (Library, Data binding enabled)
Main module depends on the Lib module. Lib module contains all the android tests. When I run the androidTests of just lib module with testCoverageEnabled it throws some weird data binding error. All these error are for custom bindings.
:core:compileDebugAndroidTestJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:compileDebugAndroidTestJavaWithJavac'.
> java.lang.RuntimeException: Found data binding errors.
Cannot find the setter for attribute 'app:marginStart' with parameter type int on android.widget.LinearLayout.
file:///Users/Ajit/projects/myProject/core/build/intermediates/bundles/debug/res/layout/my_layout.xml Line:25
To resolve this, I copied the custom binding java classes to androidTest folder and that solved the above error. But then it started complaining around the BR properties. Seems like its not able to resolve the BR.java class.
MyBinding.java:87: error: cannot find symbol
case BR.name: {
Have someone face similar issue? Any kind of help would be appreciated. Thanks!
Update: When I set testCoverageEnabled = true and apply plugin: 'com.android.library', it does not generate the BR.class in the build/intermidiates/androidTest folder.
Build folder with apply plugin: 'com.android.application'
Build folder with apply plugin: 'com.android.library'
来源:https://stackoverflow.com/questions/38644243/android-multi-module-project-with-testcoverageenabled-throws-data-binding-errors