问题
I use Android Studio 2.0 RC 1. Today android studio gave itself a mistake.
Error:Execution failed for task ':app:packageDebug'. com.android.builder.packaging.PackagerException: java.io.IOException: Failed to read zip file 'D:\Unimag\MyUnimax21042016\app\ build\outputs\apk\app-debug.apk'.
My gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "kz.dreamwings.unimax"
minSdkVersion 15
targetSdkVersion 23
versionCode 2
versionName "0.0.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.rahatarmanahmed:circularprogressview:2.5.0'
}
And full message from Messages Gradle Build
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72321Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE
:app:prepareComGithubRahatarmanahmedCircularprogressview250Library UP-TO-DATE
:app:prepareComJoanzapataIconifyAndroidIconify222Library UP-TO-DATE
:app:prepareComJoanzapataIconifyAndroidIconifyFontawesome222Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:prePackageMarkerForDebug
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug FAILED
Error:Execution failed for task ':app:packageDebug'.
> com.android.builder.packaging.PackagerException: java.io.IOException: Failed to read zip file 'D:\Unimag\MyUnimax21042016\app\build\outputs\apk\app-debug.apk'.
Information:BUILD FAILED
Information:Total time: 0.648 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
回答1:
I was able to reproduce the issue on a clean project with one of Android Studio's activity templates. For me the problem was preview version of gradle plugin. Are you using Android Studio 2.2 Preview 1? If yes then find this line in your build.gradle:
classpath 'com.android.tools.build:gradle:+
and change it to:
classpath 'com.android.tools.build:gradle:2.1.0'
For me this solved the problem.
回答2:
This happened to me when switching GIT branches. It worked to just run Build
-> Clean Project
.
MacOS 10.12 Sierra
回答3:
I try manual delete file, but the SO inform: the file "app-debug.apk" is in use by "OpenJDK Platform Binary". Then I kill "OpenJDK Platform Binary" and this worked.
回答4:
remove platform and install it once again , just this.
来源:https://stackoverflow.com/questions/37363571/errorexecution-failed-for-task-apppackagedebug-com-android-builder-packa