Importing an ancient eclipse android project of mine in android studio. Build fails with:
ImmutableJarInput{name=main, file=C:\Dropbox\eclipse_workspaces\_android_studio\monitoringModel\build\intermediates\transforms\mergeJavaRes\release\jars\2\3\main.jar, contentTypes=RESOURCES, scopes=PROJECT,PROJECT_LOCAL_DEPS, status=NOTCHANGED}
ImmutableDirectoryInput{name=release, file=C:\Dropbox\eclipse_workspaces\_android_studio\monitoringModel\build\intermediates\classes\release, contentTypes=CLASSES, scopes=PROJECT, changedFiles={}}
:monitoringModel:transformClassesAndResourcesWithSyncLibJarsForRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':monitoringModel:transformClassesAndResourcesWithSyncLibJarsForRelease'.
> java.util.zip.ZipException: ZIP file must have at least one entry
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':monitoringModel:transformClassesAndResourcesWithSyncLibJarsForRelease'.
...
Caused by: java.lang.RuntimeException: java.util.zip.ZipException: ZIP file must have at least one entry
...
Caused by: java.util.zip.ZipException: ZIP file must have at least one entry
New to gradle - how should I debug this ?
Well there is a file build.gradle
where I read:
dependencies {
compile project(':androidHelpers')
compile files('libs/zip4j-1.3.1-javadoc.jar')
compile files('libs/zip4j_1.3.1.jar')
}
Now libs/zip4j-1.3.1-javadoc.jar
was not meant to be compiled (obviously) - was excluded in eclipse project files, bug number one.
So I went ahead and commented it out:
dependencies {
compile project(':androidHelpers')
// compile files('libs/zip4j-1.3.1-javadoc.jar')
compile files('libs/zip4j_1.3.1.jar')
}
The IDE helpfully informed me that build files changed and I should "sync" - which I did and kept getting the same exception ! So I thought it was the other file and that led me to a goose chase - I unpacked it and repacked it etc following random google advice. Neither the exception or (of course) the debug output referred to the problematic file. The console was displaying:
Error:java.util.zip.ZipException: error in opening zip file
y be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a>
<a href="syncProject">Re-download dependencies and sync project (requires network)</a>
(sic - second bug) which made me think it was the libs/zip4j_1.3.1.jar that was problematic. Well turns out to be that sync
was not enough - I had to Build > Clean Project
cause gradle (despite sync) was trying to compile the javadoc zip that had cached somewhere (third bug):
Input file C:\\Dropbox\\eclipse_workspaces_android_studio\\monitoringModel\\build\\intermediates\\bundles\\release\\libs\\zip4j-1.3.1-javadoc.jar has been added.
Three bugs and counting - if anyone knows how to avoid these pitfalls - or actually why on earth gradle keeps its cache when syncing please comment.
I change
dependencies {
compile project(':androidHelpers')
compile files('libs/zip4j-1.3.1-javadoc.jar')
compile files('libs/zip4j_1.3.1.jar')
}
to
dependencies {
compile project(':androidHelpers')
provide files('libs/zip4j-1.3.1-javadoc.jar')
provide files('libs/zip4j_1.3.1.jar')
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.