使用TestCoverageEnabled的Android多模块项目引发数据绑定错误

时间:2016-07-28 18:34:30

标签: android multi-module android-databinding test-coverage

我有一个多模块项目,其结构类似于此。 以下是解决此错误的代码:https://github.com/ajitsing/MultiModuleAndroid

Root
   |- App Module (Application, Data binding enabled)
   |- Lib Module (Library, Data binding enabled)

主模块取决于Lib模块。 Lib模块包含所有的android测试。当我使用testCoverageEnabled运行lib模块的androidTests时,它会引发一些奇怪的数据绑定错误。所有这些错误都是针对自定义绑定的。

: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

要解决此问题,我将自定义绑定java类复制到androidTest文件夹,这解决了上述错误。但随后它开始抱怨BR的财产。好像它无法解析BR.java类。

MyBinding.java:87: error: cannot find symbol
        case BR.name: {

有人面临类似的问题吗?任何形式的帮助将不胜感激。谢谢!

更新 当我设置 testCoverageEnabled = true 应用插件:'com.android.library'时,它不会在build / intermidiates / androidTest文件夹中生成BR.class。 / p>

使用应用插件构建文件夹:'com.android.application'

enter image description here

使用应用插件构建文件夹:'com.android.library'

enter image description here

0 个答案:

没有答案