意外的顶级例外:DexException:多DEX文件定义 - Hamcrest [英] UNEXPECTED TOP-LEVEL EXCEPTION: DexException: Multiple dex files define -- Hamcrest

查看:206
本文介绍了意外的顶级例外:DexException:多DEX文件定义 - Hamcrest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行从androidTest目录下的一个方法,我得到这个错误。目前,我正在试图测试出居preSSO UI测试,我遇到下面的错误描述。

I get this error when I run a method from under the androidTest directory. I'm currently attempting to test out Espresso UI testing, and I encounter the error depicted below.

我看了堆栈溢出其他类似的问题,并根据他们的回答,似乎有重复的类。我不能完全确定哪些类是重复的;我试图寻找MatcherAssert专(由第四图所示),但由于我是新来的Andr​​oid,我不能完全肯定,如果有应该是所有三个hamcrest核心,集成和图书馆。可能有其他冲突一样好,但我真的很AP preciate什么复制存在任何指导。

I've looked at other similar questions on Stack Overflow, and according to their answers, it seems that there are duplicated classes. I am not entirely sure which classes are duplicated; I tried searching for MatcherAssert specifically (shown by the fourth picture), but since I'm new to Android, I'm not entirely sure if there are supposed to be all three of hamcrest-core, integration, and library. There are probably other conflicts as well, but I would really appreciate any guidance on what duplicates there are.

我目前使用的buildToolsVersion 21.1.2。关于非零值2,我尝试添加

I am currently using buildToolsVersion 21.1.2. Regarding the "non-zero exit value 2," I tried adding

multiDexEnabled true

推荐答案

现在的错误是固定的。

我所做的是我删除

androidTestCompile 'com.android.support.test:testing-support-lib:0.1'

这的build.gradle,并从2.1更新长者preSSO至2.2。

from build.gradle, and updated Espresso from 2.1 to 2.2.

我意识到我没有我的长者preSSO测试用例中添加仪表注册,所以我补充说,每官方Android开发网站。

I realized I did not add Instrumentation Registry within my Espresso test case, so I added that per the official Android development website.

在我无效缓存(文件 - >的Invalidate缓存/重新启动),重新启动,然后清理和重建一切。我跑测试的情况下,错误不再发生。

After that I invalidated caches (File -> Invalidate Caches/ Restart), restarted and then cleaned and rebuilt everything. I ran the test case, the error no longer occurred.

我不完全了解是什么导致了错误,但由于上面的步骤,现在它得到过去过去的障碍。

I do not fully understand what caused the error, but due to the above steps, now it gets past the past roadblock.

这篇关于意外的顶级例外:DexException:多DEX文件定义 - Hamcrest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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