简体   繁体   English

在Android Studio中构建proguard。 得到错误

[英]proguard build in Android Studio. Getting error

I am trying to config the proguard in android studio for my release build but I am getting error and warnings below: 我正在尝试在android studio中为我的发布版本配置proguard,但我收到错误和警告如下:

Error:Execution failed for task ':myAccount_S:proguardRelease'. 错误:任务':myAccount_S:proguardRelease'的执行失败。

java.io.IOException: Can't write [C:\\Users\\mgi\\AndroidStudioProjects\\MyProjects\\myAccount_S\\build\\intermediates\\classes-proguard\\release\\classes.jar] (Can't read [C:\\Users\\mgi\\AndroidStudioProjects\\MyAccountProjects\\myAccount_S\\build\\intermediates\\exploded-aar\\MyAccountProjects\\myLibrary\\unspecified\\libs\\PushTracker-1.3.0-tracfone.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [PushTracker-1.3.0-tracfone.jar:com/mgage/push/tracker/PushManager$1.class])) :myAccount_S:proguardRelease FAILED Warning:can't write resource [META-INF/NOTICE] (Duplicate zip entry [jackson-databind-2.2.3.jar:META-INF/NOTICE]) Warning:can't write resource [META-INF/LICENSE] (Duplicate zip entry [jackson-databind-2.2.3.jar:META-INF/LICENSE]) java.io.IOException:无法写[C:\\ Users \\ mgi \\ AndroidStudioProjects \\ MyProjects \\ myAccount_S \\ build \\ intermediates \\ classes-proguard \\ release \\ classes.jar](无法读取[C:\\ Users \\ mgi] \\ AndroidStudioProjects \\ MyAccountProjects \\ myAccount_S \\ build \\ intermediates \\ explosion-aar \\ MyAccountProjects \\ myLibrary \\ unspecified \\ libs \\ PushTracker-1.3.0-tracfone.jar(;;;;;;!META-INF / MANIFEST.MF)](重复的zip条目[PushTracker-1.3.0-tracfone.jar:com / mgage / push / tracker / PushManager $ 1.class])):myAccount_S:proguardRelease FAILED警告:无法写入资源[META-INF / NOTICE](重复zip条目[jackson-databind-2.2.3.jar:META-INF / NOTICE])警告:无法写入资源[META-INF / LICENSE](重复的zip条目[jackson-databind-2.2.3.jar:META] -INF / LICENSE])

gradle:

 buildTypes { release { minifyEnabled true proguardFile getDefaultProguardFile('proguard-android.txt') } } packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/MANIFEST' } dependencies { 

buildTypes { release { minifyEnabled true proguardFile getDefaultProguardFile('proguard-android.txt') } } packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/MANIFEST' } dependencies {

 compile project(':facebookSDK') compile 'com.android.support:support-v4:19.1.0' compile 'com.android.support:appcompat-v7:19.1.0' compile 'com.google.android.gms:play-services:6.5.87' compile files('libs/BxLibrary-1.4.14.jar') compile files('libs/commons-io-1.3.2.jar') compile files('libs/jackson-annotations-2.2.3.jar') compile files('libs/jackson-core-2.2.3.jar') compile files('libs/jackson-databind-2.2.3.jar') compile files('libs/libGoogleAnalyticsServices.jar') compile files('libs/PushTracker-1.3.0.jar') compile files('libs/robospice-1.4.14.jar') compile files('libs/robospice-cache-1.4.14.jar') 

} }

This can only arise when jackson-databind-2.2.3.jar is being used by more than 1 project. 只有当jackson-databind-2.2.3.jar被多个项目使用时才会出现这种情况。 The only resolution is to either use maven central repository or create a third project and use it as a dependency in the projects using jackson-databind-2.2.3.jar earlier. 唯一的解决方案是使用maven中央存储库或创建第三个项目,并使用前面的jackson-databind-2.2.3.jar将其用作项目中的依赖项。

It seems that the problem is caused by conflicting LICENSE, NOTICE and other files. 似乎问题是由LICENSE,NOTICE和其他文件冲突引起的。 Instead of excluding, check if something like this fixes the issue: 而不是排除,检查这样的事情是否解决了问题:

packagingOptions {
    pickFirst 'META-INF/NOTICE'
    pickFirst 'META-INF/LICENSE'
    pickFirst 'META-INF/MANIFEST'
    pickFirst 'META-INF/LICENSE.txt'
    pickFirst 'META-INF/NOTICE.txt'
    pickFirst 'META-INF/MANIFEST'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM