1

我尝试了不同的 IDE 和操作系统,但有相同的错误。也许我做错了什么?

Intellij Idea Ultimate 中的步骤:

  1. 创建新的 Android 应用程序项目。
  2. 将 espresso-1.1-bundled.jar 复制到 libs 文件夹中。
  3. 添加为库。
  4. 构建项目。

结果:

Error:Android Pre Dex: [espresso-1.1-bundled.jar] UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Android Pre Dex: [espresso-1.1-bundled.jar] java.util.zip.ZipException: error in opening zip file
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at java.util.zip.ZipFile.open(Native Method)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at java.util.zip.ZipFile.<init>(ZipFile.java:215)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at java.util.zip.ZipFile.<init>(ZipFile.java:145)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at java.util.zip.ZipFile.<init>(ZipFile.java:159)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at com.android.dx.command.dexer.Main.processOne(Main.java:596)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at com.android.dx.command.dexer.Main.run(Main.java:230)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at java.lang.reflect.Method.invoke(Method.java:606)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:161)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:294)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)
Error:Android Pre Dex: [espresso-1.1-bundled.jar] 1 error; aborting
4

1 回答 1

0
    Make sure you have installed the latest Android Support Repository under Extras (see instructions).
    Open your app’s build.gradle file. This is usually not the top-level build.gradle file but app/build.gradle.
    Add the following lines inside dependencies:

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5
于 2017-04-25T07:05:41.440 回答