Proguard 异常 java.io.IOException:重复的 zip 条目
Proguard Exception java.io.IOException: Duplicate zip entry
在使用 proguard 构建应用程序以发布时出现此错误。
任务“:app:transformClassesAndResourcesWithProguardForRelease”执行失败。
Warning:Exception while processing task java.io.IOException: Can't write
[C:\Users\sagar.HP\AndroidStudioProjects\MyApp\app\build\intermediates\
transforms\proguard\release\jarsf\main.jar] (Can't read
[C:\Users\sagar.HP\.android\build-
cache\bf0ee9d089eb4a68c393\output\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [com/google/android/gms/internal/bs.class ==
classes.jar:com/google/android/gms/internal/zzas.class]))
build.gradle 文件:
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.ardent.sys.telugulivetv"
minSdkVersion 17
targetSdkVersion 25
versionCode 12
versionName "2.3.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.each { output ->
project.ext { appName = 'Telugu Live TV' }
def formattedDate = new Date().format('yyyyMMddHHmmss')
def newName = output.outputFile.name
newName = newName.replace("app-", "$project.ext.appName-") //"MyAppName" -> I set my app variables in the root project
newName = newName.replace("-release", "-release" + formattedDate)
//noinspection GroovyAssignabilityCheck
output.outputFile = new File(output.outputFile.parent, newName)
}
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile ('com.adincube.sdk:AdinCube-Java-206ebf:1.+@aar') {
transitive = true
}
compile('com.adincube.sdk:AdinCube-Native-RecyclerView-Extension:1.+') {
transitive = true
}
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.1'
compile 'com.google.firebase:firebase-crash:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.8.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Proguard-rules.pro
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
-dontwarn com.squareup.okhttp.**
我阅读了所有相关问题,但这并没有解决我的问题。请帮我解决这个错误。
audience-network-sdk
facebook 模块使用的 play-service-ads
与 firebase 模块使用的 play-service-ads
之间存在冲突。以下将修复它:
compile('com.facebook.android:audience-network-sdk:4.+') {
exclude module: 'play-services-ads'
}
compile 'com.google.android.gms:play-services-ads:11.0.2'
但在那之后,你又遇到了一个冲突(这次与play-service无关):
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/facebook/ads/AbstractAdListener.class
发生这种情况是因为 com.adincube.sdk:AdinCube-Java-206ebf
包含对 com.adincube.partner:facebook
的依赖项,其包名称为 com.facebook.ads
。我猜这是 facebook 库的一个非官方修改包。如果你确定你不需要这个依赖,你可以排除它:
compile('com.adincube.sdk:AdinCube-Java-206ebf:1.+@aar') {
transitive = true
exclude module: 'facebook'
}
否则请联系 adincube.com 以获取有关将其模块与 com.facebook.android:audience-network-sdk
集成的说明
在使用 proguard 构建应用程序以发布时出现此错误。
任务“:app:transformClassesAndResourcesWithProguardForRelease”执行失败。
Warning:Exception while processing task java.io.IOException: Can't write
[C:\Users\sagar.HP\AndroidStudioProjects\MyApp\app\build\intermediates\
transforms\proguard\release\jarsf\main.jar] (Can't read
[C:\Users\sagar.HP\.android\build-
cache\bf0ee9d089eb4a68c393\output\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [com/google/android/gms/internal/bs.class ==
classes.jar:com/google/android/gms/internal/zzas.class]))
build.gradle 文件:
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.ardent.sys.telugulivetv"
minSdkVersion 17
targetSdkVersion 25
versionCode 12
versionName "2.3.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.each { output ->
project.ext { appName = 'Telugu Live TV' }
def formattedDate = new Date().format('yyyyMMddHHmmss')
def newName = output.outputFile.name
newName = newName.replace("app-", "$project.ext.appName-") //"MyAppName" -> I set my app variables in the root project
newName = newName.replace("-release", "-release" + formattedDate)
//noinspection GroovyAssignabilityCheck
output.outputFile = new File(output.outputFile.parent, newName)
}
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile ('com.adincube.sdk:AdinCube-Java-206ebf:1.+@aar') {
transitive = true
}
compile('com.adincube.sdk:AdinCube-Native-RecyclerView-Extension:1.+') {
transitive = true
}
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.1'
compile 'com.google.firebase:firebase-crash:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.8.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Proguard-rules.pro
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
-dontwarn com.squareup.okhttp.**
我阅读了所有相关问题,但这并没有解决我的问题。请帮我解决这个错误。
audience-network-sdk
facebook 模块使用的 play-service-ads
与 firebase 模块使用的 play-service-ads
之间存在冲突。以下将修复它:
compile('com.facebook.android:audience-network-sdk:4.+') {
exclude module: 'play-services-ads'
}
compile 'com.google.android.gms:play-services-ads:11.0.2'
但在那之后,你又遇到了一个冲突(这次与play-service无关):
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/facebook/ads/AbstractAdListener.class
发生这种情况是因为 com.adincube.sdk:AdinCube-Java-206ebf
包含对 com.adincube.partner:facebook
的依赖项,其包名称为 com.facebook.ads
。我猜这是 facebook 库的一个非官方修改包。如果你确定你不需要这个依赖,你可以排除它:
compile('com.adincube.sdk:AdinCube-Java-206ebf:1.+@aar') {
transitive = true
exclude module: 'facebook'
}
否则请联系 adincube.com 以获取有关将其模块与 com.facebook.android:audience-network-sdk