Espresso-android jar-Android Studio 8.x中的“打开zip文件时出错" [英] Espresso-android jar - 'Error in opening zip file' in android studio 8.x
问题描述
I've been getting this error, I've tried the solution stated here: Android studio - Failed to complete gradle execution - error in opening zip file
此错误使我丧命,我尝试删除.gradle文件夹.我注意到.idea \ libraries文件夹中有一堆xml,我试着删除它(认为它存储了错误的东西),事实并非如此.
This error is killing me, I've tried removing the .gradle folder. I've noticed that the .idea\libraries folder has a bunch of xml's in it and I've tried deleting that (thinking its storing something wrong) and that wasn't it either.
我将其范围缩小到从espresso-android网站espresso-1.1.jar和测试运行程序下载的jars-我已经验证了在没有依赖项的情况下可以正常工作.而且,一旦添加它们,它就不会添加.我什至可以添加其他依赖项,并且它可以正常工作.所以我不知道为什么这些Jar是例外,但它们不起作用.
I've narrowed it down to the jars downloaded from the espresso-android site, espresso-1.1.jar and the test runners - I've verified that without them in the dependencies it works. And as soon as they've been added it doesn't. I can even add other dependencies and it works. So I don't know why these Jars are the exception but they don't work.
:app:compileDebugJava
error: error reading /Users/busyer_jonathan/AndroidStudioProjects/TestVersion/app/libs/testrunner-runtime-1.1.jar; error in opening zip file
error: error reading /Users/busyer_jonathan/AndroidStudioProjects/TestVersion/app/libs/testrunner-1.1.jar; error in opening zip file
error: error reading /Users/busyer_jonathan/AndroidStudioProjects/TestVersion/app/libs/testrunner-runtime-1.1.jar; error in opening zip file
error: error reading /Users/busyer_jonathan/AndroidStudioProjects/TestVersion/app/libs/testrunner-1.1.jar; error in opening zip file
:app:preDexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:214)
at java.util.zip.ZipFile.<init>(ZipFile.java:144)
at java.util.zip.ZipFile.<init>(ZipFile.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --output /Users/busyer_jonathan/AndroidStudioProjects/TestVersion/app/build/intermediates/pre-dexed/debug/testrunner-runtime-1.1-9d180daedad4578babced4673aa1a80a8f70f413.jar /Users/busyer_jonathan/AndroidStudioProjects/TestVersion/app/libs/testrunner-runtime-1.1.jar
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:214)
at java.util.zip.ZipFile.<init>(ZipFile.java:144)
at java.util.zip.ZipFile.<init>(ZipFile.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
这是我的构建文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.edu.testversion"
minSdkVersion 16
targetSdkVersion 20
versionCode 1
versionName "1.0"
//testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/json_simple-1.1.jar',
'libs/testrunner-1.1.jar',
'libs/testrunner-runtime-1.1.jar')
compile files('libs/scribe-1.3.5.jar')
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.android.gms:play-services:5.0.77'
compile 'com.android.support:appcompat-v7:20.0.0'
androidTestCompile 'org.mockito:mockito-core:1.9.+'
androidTestCompile 'org.objenesis:objenesis:1.2'
//Espresso dependencies includes guava, hamcrest, dagger, javax annotation
androidTestCompile 'com.google.guava:guava:14.0.1',
'com.squareup.dagger:dagger:1.1.0',
'org.hamcrest:hamcrest-integration:1.1',
'org.hamcrest:hamcrest-library:1.1'
}
推荐答案
我发现问题是我正在从espresso网站下载罐子: https://code.google.com/p/android-test-kit/source/browse/#git 通过右键单击它们并单击另存为"(确实下载了jar),它们只是出于某种奇怪的原因而无法工作.甚至重复一遍,它们仍然不起作用-我检查了我的权限(因为我有Mac机,但它有点敏感).
The problem, I found, was that I was downloading the jars from the espresso site : https://code.google.com/p/android-test-kit/source/browse/#git by right clicking on them and clicking 'Save as'- which did indeed download the jars, they just did not work for some odd reason. Even repeating this, they still did not work - I checked that I had permission (since I have a mac and its a bit touchy).
我必须以zip格式下载所有文件,解压缩整个文件,然后手动将所需的所有jar拖放到各自的文件夹中.
I had to download all of the files as a zip, unzip the whole thing, and hand pick and drag all the jars I needed out of their respective folders.
您将看到下载zip" 在屏幕右下角抓取.这就是我单击并解压缩工作罐的过程.
you'll see the 'download zip' in the bottom right of the screen grab. That is what I clicked and unzipped for the working jars.
这篇关于Espresso-android jar-Android Studio 8.x中的“打开zip文件时出错"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!