3

I am trying to config the proguard in android studio for my release build but I am getting error and warnings below:

Error:Execution failed for task ':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])

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 {

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')

}

  • Please post you build.gradle file. It seems two of your dependencies declare the jackson library and that is causing the error. – Edson Menegatti Jun 01 '15 at 16:01
  • possible duplicate of http://stackoverflow.com/questions/20673625/android-gradle-plugin-0-7-0-duplicate-files-during-packaging-of-apk – Piyush Agarwal Jun 01 '15 at 16:01
  • 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' } – user3152367 Jun 01 '15 at 16:06

2 Answers2

1

This can only arise when jackson-databind-2.2.3.jar is being used by more than 1 project. 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.

Varun Bhatia
  • 4,326
  • 32
  • 46
-1

It seems that the problem is caused by conflicting LICENSE, NOTICE and other files. 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'
}
dkarmazi
  • 3,199
  • 1
  • 13
  • 25
  • I am able to generate the apk now but it is unaligned apk. how can I know that I implemented proguard correctly? I never used before. I am getting notification says that apk is successfully generated. – user3152367 Jun 01 '15 at 20:22
  • it depends on what exactly your proguard was supposed to be doing, but generally reduced size of APK is a good indication. Another indication is having files, generated by proguard, such as aapt_rules.txt (in yourprojectdir/build/intermediates/proguard-rules/your-build-variant You can also lookup other solutions here: http://stackoverflow.com/questions/10190907/how-to-tell-if-proguard-has-done-its-job – dkarmazi Jun 01 '15 at 20:51
  • that is what i did to use aapt_rules.txt and I did not do any changes in aapt_rules.txt. but generating unaligned apk and I am not able to install it on a device. cant be installed – user3152367 Jun 01 '15 at 21:21
  • could you please post your proguard-android.txt, it might be the case that proguard is stripping off more than it should – dkarmazi Jun 01 '15 at 22:33
  • whoever downvoted, please provide some feedback, what was the problem you were trying to solve in the first place? Was it exactly the same error message in your logs? There might be a room to improve this answer. – dkarmazi Jan 12 '16 at 17:04