Android Multi Module Project With TestCoverageEnabled Throws Data Binding Errors

守給你的承諾、 提交于 2019-12-10 20:42:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!