Error:Execution failed for task ':app:packageRelease'. > java.io.IOException: Failed to read zip file
Error:Execution failed for task ':app:packageRelease'. > java.io.IOException: Failed to read zip file
当我尝试构建发布版本时出现以下错误。我正在使用 android studio 2.3 。我在下面添加了我的 gradle 和 proguard 规则文件,我将使用 mac 和 mac os X
Error:Execution failed for task ':app:packageRelease'.
> java.io.IOException: Failed to read zip file '/Users/username/Documents/Android Projects/Project Name/app/build/intermediates/transforms/proguard/release/jars/3/1f/main.jar'.
proguard 规则文件
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keepattributes JavascriptInterface
-keepattributes *Annotation*
-dontwarn com.razorpay.**
-keep class com.razorpay.** {*;}
-optimizations !method/inlining/*
-keepclasseswithmembers class * {
public void onPayment*(...);
}
-keep @interface butterknife.*
-keepclasseswithmembers class * {
@butterknife.* <fields>;
}
-keepclasseswithmembers class * {
@butterknife.* <methods>;
}
-keepclasseswithmembers class * {
@butterknife.On* <methods>;
}
-keep class **$$ViewInjector {
public static void inject(...);
public static void reset(...);
}
-keep class **$$ViewBinder {
public static void bind(...);
public static void unbind(...);
}
-keep class com.google.common.** {*;}
-dontwarn sun.misc.Unsafe
-dontwarn javax.annotation.**
gradle 文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.company.projectname"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.razorpay:checkout:1.2.1'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'jp.wasabeef:picasso-transformations:2.1.0'
compile 'com.makeramen:roundedimageview:2.3.0'
compile 'com.github.greenfrvr:hashtag-view:1.2.1'
compile 'com.leaking.slideswitch:slideswitch:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.github.devlight:infinitecycleviewpager:1.0.2'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
testCompile 'junit:junit:4.12'
}
项目级别gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://dl.bintray.com/leaking/maven'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
此问题已在包含非 ASCII class 名称的项目中引用 here。该问题将从 gradle Android 插件的 2.4 版开始解决(目前尚未发布)。
另一种方法是降级到 2.2.3 :
classpath 'com.android.tools.build:gradle:2.2.3'
对我来说,这个错误发生在我在 Windows 上构建项目时,其中写入权限仅授予管理员用户,并且 Android studio 是在常规模式下启动的(不是管理员模式) .当我使用 "Run as administrator" 启动 Android studio 时,写入权限可用并且 .apk 已成功生成。
当我尝试构建发布版本时出现以下错误。我正在使用 android studio 2.3 。我在下面添加了我的 gradle 和 proguard 规则文件,我将使用 mac 和 mac os X
Error:Execution failed for task ':app:packageRelease'.
> java.io.IOException: Failed to read zip file '/Users/username/Documents/Android Projects/Project Name/app/build/intermediates/transforms/proguard/release/jars/3/1f/main.jar'.
proguard 规则文件
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keepattributes JavascriptInterface
-keepattributes *Annotation*
-dontwarn com.razorpay.**
-keep class com.razorpay.** {*;}
-optimizations !method/inlining/*
-keepclasseswithmembers class * {
public void onPayment*(...);
}
-keep @interface butterknife.*
-keepclasseswithmembers class * {
@butterknife.* <fields>;
}
-keepclasseswithmembers class * {
@butterknife.* <methods>;
}
-keepclasseswithmembers class * {
@butterknife.On* <methods>;
}
-keep class **$$ViewInjector {
public static void inject(...);
public static void reset(...);
}
-keep class **$$ViewBinder {
public static void bind(...);
public static void unbind(...);
}
-keep class com.google.common.** {*;}
-dontwarn sun.misc.Unsafe
-dontwarn javax.annotation.**
gradle 文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.company.projectname"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.razorpay:checkout:1.2.1'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'jp.wasabeef:picasso-transformations:2.1.0'
compile 'com.makeramen:roundedimageview:2.3.0'
compile 'com.github.greenfrvr:hashtag-view:1.2.1'
compile 'com.leaking.slideswitch:slideswitch:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.github.devlight:infinitecycleviewpager:1.0.2'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
testCompile 'junit:junit:4.12'
}
项目级别gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://dl.bintray.com/leaking/maven'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
此问题已在包含非 ASCII class 名称的项目中引用 here。该问题将从 gradle Android 插件的 2.4 版开始解决(目前尚未发布)。
另一种方法是降级到 2.2.3 :
classpath 'com.android.tools.build:gradle:2.2.3'
对我来说,这个错误发生在我在 Windows 上构建项目时,其中写入权限仅授予管理员用户,并且 Android studio 是在常规模式下启动的(不是管理员模式) .当我使用 "Run as administrator" 启动 Android studio 时,写入权限可用并且 .apk 已成功生成。