运行多种意式浓缩咖啡.APK [英] Running a Multidexed Espresso .APK

查看:68
本文介绍了运行多种意式浓缩咖啡.APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用./gradlew connectedDebugAndroidTest运行Espresso测试时,我们遇到了以下问题:

When running Espresso tests with ./gradlew connectedDebugAndroidTest, we're having this issue:

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException:方法ID不在[0, 0xffff]:65536

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

由于我们在主应用程序上使用Multidex,并且仅在已测试的测试对象上添加了Espresso依赖项,所以我们不明白为什么它不起作用:·(另外,如果我们改为通过IntelliJ运行测试,的Gradle,它的工作原理:·|

As we're using Multidex at the main app and just adding the Espresso dependencies on the instrumented test one, we don't get why it doesn't work :·( In addition, if we run the tests via IntelliJ instead of Gradle, it works :·|

顺便说一句,我们需要通过Gradle运行它们以在CI工具上使它们自动化.

By the way, we need to run them via Gradle to automate them on the CI tool.

更多信息?在Google的问题跟踪器上,有一个指向相关问题的链接: https://issuetracker.google.com/issues/37017515 :sad:

More information? There's a link to a related issue on Google's issue tracker: https://issuetracker.google.com/issues/37017515 :sad:

推荐答案

任务connectedDebugAndroidTest将尝试为项目中的每个模块构建测试apk,因此,如果项目中有多个模块,则需要在每个模块中启用multidex.其中之一.通常是通过设置完成

The task connectedDebugAndroidTest will try to build test apks for every module in the project, so if you project has multiple modules, you need to enable multidex in every one of them. This is usually done setting

android.defaultConfig.multiDexEnabled true

build.gradle中每个模块.

如果您不尝试在其中执行任务,则可以对没有任何测试的模块跳过所有这些操作.例如,如果仅app模块具有检测测试,则可以执行app:connectedDebugAndroidTest来避免可能的multidex错误.实际上,这实际上是Android Studio创建的运行配置的默认设置,这可能是从IDE启动测试时测试运行正常的原因.

You could skip all of this for modules that don't have any tests if you just don't try to execute the task in those. e.g, if only the app module has instrumentation tests, you could execute app:connectedDebugAndroidTest instead to avoid the possible multidex errors. This is actually what the run configuration created by Android Studio does by default, and probably the reason why your tests are running just fine when you launch them form the IDE.

这篇关于运行多种意式浓缩咖啡.APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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