引入数据绑定后无法运行检测测试 [英] Cannot run instrumentation tests after I introduced databinding

查看:79
本文介绍了引入数据绑定后无法运行检测测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要

Warning: library class android.databinding.DataBindingUtil depends on program class android.databinding.DataBindingComponent

在将数据绑定引入我的项目后,尝试运行gradle任务assembleItestAndroidTest时,出现此错误. (我有一个单独的用于仪器测试的构建配置,我称之为itest,另外两个是调试和发布)

I get this when attempting to run the gradle task assembleItestAndroidTest after introducing data binding to my project. (I have a separate build config for instrumentation testing which I call itest, the other two being debug and release)

该如何解决?

编辑:我认为这是一个android-gradle构建工具错误或Android数据绑定错误.我已向Google提交了错误报告,其中包含有关如何复制的完整说明.

edit: I think this is a android-gradle build tool bug or Android Data Binding bug. I've filed a bug report to Google with full instructions on how to reproduce.

此处的关键是将构建类型配置为运行压缩.因此,只要您依赖数据绑定,用于测试测试的除debug以外的任何构建类型都将失败.

The key here is that the build type is configured to run minification. So any build type other than debug for the instrumentation test will fail as long as you rely on data binding.

对于任何将持续集成作为其生产周期不可或缺的部分的公司而言,这几乎是一个制胜法宝,所以我希望Google优先考虑这一点.

This is pretty much a show-stopper for any company having continous integration as an integral part of their production cycle so I hope Google prioritize this high.

推荐答案

尝试将以下内容添加到您的proguard配置中:

Try adding the following to your proguard config:

-dontwarn android.databinding.**
-keep class <whatever your package name in AndroidManifest is>.databinding.** {
    <fields>;
    <methods>;
}

第一行摆脱了警告,第二行告诉Proguard不要弄乱任何生成的类.

The first line gets rid of the warning, and the second tells proguard to not mess with any of the generated classes.

这篇关于引入数据绑定后无法运行检测测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆