我一直在收到此错误,我已尝试过此处所述的解决方案:Android studio - Failed to complete gradle execution - error in opening zip file
此错误导致我死亡,我已尝试删除.gradle文件夹。我注意到.idea \ libraries文件夹中有一堆xml,我已经尝试删除它(认为它存储错误),那也不是。
我已经将它缩小到从espresso-android网站espresso-1.1.jar和测试跑步者下载的罐子里 - 我已经验证了它们在依赖项中没有它们的作用。一旦它们被添加它就没有了。我甚至可以添加其他依赖项,它的工作原理。所以我不知道为什么这些罐子是例外但它们不起作用。
: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'
}
答案 0 :(得分:2)
问题,我发现,我正在从espresso网站下载罐子:https://code.google.com/p/android-test-kit/source/browse/#git右键点击它们并点击“另存为” - 这确实下载了罐子,它们只是没有工作出于某种奇怪的原因。即使重复这一点,他们仍然无法正常工作 - 我检查了我的许可(因为我有一个mac,它有点敏感)。
我必须将所有文件作为zip文件下载,解压缩整个文件,然后手动挑选并拖动我需要的所有文件夹。
修改:您会在屏幕右下角看到'下载压缩'。这就是我为工作罐点击并解压缩的内容。