1

I've been trying to get ProGuard to run the past 2 days, just can't get past this problem.

Full error

java.io.IOException: Can't write [/PATH_TO_POJECT/build/intermediates/classes-proguard/release/classes.jar] (Can't read [/PATH_TO_POJECT/build/intermediates/exploded-aar/com.facebook.android/FaceBook320/3.20.0/libs/android-support-v13.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [android-support-v13.jar:android/support/v13/app/FragmentCompat$ICSFragmentCompatImpl.class]))

I'm using Android Studio. My Project contains a few different modules, two of those modules depend on android-support-v13.jar. I've made sure that the android-support-v13.jar's are the same across each module.

I've also tried excluding the the support jars from the modules like so: build.gradle

compile (project(':FaceBook320')){
    exclude module: 'support-v13'
    exclude module: 'support-v4'
}

But I still get the same error.

My proguard-project.pro:

-optimizationpasses 5

#When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use:
-dontusemixedcaseclassnames

#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses

#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify

#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose

#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields).
#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

#To repackage classes on a single package
#-repackageclasses ''

#Uncomment if using annotations to keep them.
#-keepattributes *Annotation*

#Keep classes that are referenced on the AndroidManifest
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService


#To remove debug logs:
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
}

#To avoid changing names of methods invoked on layout's onClick.
# Uncomment and add specific method names if using onClick on layouts
#-keepclassmembers class * {
# public void onClickButton(android.view.View);
#}

#Maintain java native methods
-keepclasseswithmembernames class * {
    native <methods>;
}

#To maintain custom components names that are used on layouts XML.
#Uncomment if having any problem with the approach below
#-keep public class custom.components.package.and.name.**

#To maintain custom components names that are used on layouts XML:
-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

#Maintain enums
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

#To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

#Keep the R
-keepclassmembers class **.R$* {
    public static <fields>;
}

#Results classes that only extend a generic should be preserved as they will be pruned by Proguard 
#as they are "empty", others are kept
-keep class com.project.models.**
-keep class com.project.models.singleton.**

#RoboSpice requests should be preserved in most cases
-keepclassmembers class com.project.requests.** {
  public void set*(***);
  public *** get*();
  public *** is*();
}

#if you use public fields instead of setter/getters for your REST POJOs, add this
-keepclassmembers class com.project.models.** {
      public <fields>;
}

### Jackson SERIALIZER SETTINGS
-keepclassmembers,allowobfuscation class * {
    @org.codehaus.jackson.annotate.* <fields>;
    @org.codehaus.jackson.annotate.* <init>(...);
}

### Simple XML SERIALIZER SETTINGS
-keepclassmembers,allowobfuscation class * {
    @org.simpleframework.xml.* <fields>;
    @org.simpleframework.xml.* <init>(...);
}

-dontskipnonpubliclibraryclassmembers
-keepattributes *Annotation*,EnclosingMethod
 -keepnames class org.codehaus.jackson.** { *; }

#Warnings to be removed. Otherwise maven plugin stops, but not dangerous
-dontwarn android.support.**
-dontwarn android.support.v4.**
-dontwarn android.support.v13.**
-dontwarn com.sun.xml.internal.**
-dontwarn com.sun.istack.internal.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.springframework.**
-dontwarn java.awt.**
-dontwarn javax.security.**
-dontwarn java.beans.**
-dontwarn javax.xml.**
-dontwarn java.util.**
-dontwarn org.w3c.dom.**
-dontwarn com.google.common.**
-dontwarn com.octo.android.robospice.persistence.**

#-optimizationpasses 5
-dontoptimize


-keep class twitter4j.CommonsLoggingLoggerFactory
-dontwarn twitter4j.CommonsLoggingLoggerFactory
-keep class twitter4j.Log4JLogger
-dontwarn twitter4j.Log4JLogger
-keep class twitter4j.Log4JLoggerFactory
-dontwarn twitter4j.Log4JLoggerFactory
-keep class twitter4j.management.APIStatisticsOpenMBean
-dontwarn twitter4j.management.APIStatisticsOpenMBean
-keep class twitter4j.management.APIStatisticsOpenMBean
-dontwarn twitter4j.management.APIStatisticsOpenMBean
-keep class twitter4j.SLF4JLogger
-dontwarn twitter4j.SLF4JLogger
-keep class twitter4j.SLF4JLoggerFactory4
-dontwarn twitter4j.SLF4JLoggerFactory
-keep class twitter4j.TwitterAPIMonitor
-dontwarn twitter4j.TwitterAPIMonitor

-keep class android.support.v4.app.** { *; }
-keep class android.support.v4.** { *; }
-keep class android.support.v13.**{ *;}
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v13.app.** { *; }
-keep interface android.support.v13.app.** { *; }


#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify

#To remove debug logs:
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
}

#Facebook
-keep class com.facebook.** { *; }
-keepattributes Signature

#Google Play Services
-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

My full build.gradle:

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

dependencies {
    //There is an android-support-v13.jar in the libs folder.
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':PullToRefresh')
    compile project(':PinnedListView')
    compile ('com.google.android.gms:play-services:6.1.71'){
        exclude module: 'support-v13'
        exclude module: 'support-v4'
    }
    //The FaceBook320 project depends on android-support-v13.jar
    compile (project(':FaceBook320')){
        exclude module: 'support-v13'
        exclude module: 'support-v4'
    }
    //The PagerSlidingTabStrip project depends on android-support-v13.jar
    compile (project(':PagerSlidingTabStrip')){
        exclude module: 'support-v13'
        exclude module: 'support-v4'
    }
}

android {
    compileSdkVersion 19
    buildToolsVersion "20.0.0"

    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/dependencies'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/README.txt'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude '!META-INF/MANIFEST.MF'
        exclude 'META-INF/MANIFEST.MF'

    }

    lintOptions {
        checkReleaseBuilds true
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    signingConfigs {
        debug {
            storeFile file("secret.keystore")
            storePassword "secret"
            keyAlias "secret"
            keyPassword "secret"
        }
        release {
            storeFile file("secret.keystore")
            storePassword "secret"
            keyAlias "secret"
            keyPassword "secret"
        }
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')

        // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Types
        buildTypes {
            debug {
                applicationIdSuffix ""
                versionNameSuffix ""
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.pro'
                signingConfig signingConfigs.debug
            }
            release {
                applicationIdSuffix ""
                versionNameSuffix ""
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.pro'
                signingConfig signingConfigs.release
            }
        }

    }

}

Edit: After running gradlew androidDependencies

+--- LOCAL: android-support-v13.jar
+--- LOCAL: commons-io-1.3.2.jar
+--- LOCAL: commons-lang3-3.1.jar
+--- LOCAL: jackson-annotations-2.3.1.jar
+--- LOCAL: jackson-core-2.3.1.jar
+--- LOCAL: jackson-databind-2.3.1.jar
+--- LOCAL: libGoogleAnalyticsServices.jar
+--- LOCAL: robospice-1.4.9.jar
+--- LOCAL: robospice-cache-1.4.9.jar
+--- LOCAL: robospice-spring-android-1.4.9.jar
+--- LOCAL: spring-android-auth-1.0.1.RELEASE.jar
+--- LOCAL: spring-android-core-1.0.1.RELEASE.jar
+--- LOCAL: spring-android-rest-template-1.0.1.RELEASE.jar
+--- LOCAL: twitter4j-core-4.0.1.jar
+--- Droid_AS:PullToRefresh:unspecified
|    \--- Droid_AS:PinnedListView:unspecified
+--- Droid_AS:PinnedListView:unspecified
+--- com.google.android.gms:play-services:6.1.71
+--- com.facebook.android:FaceBook320:3.20.0
|    \--- LOCAL: android-support-v13.jar
\--- Droid_AS:PagerSlidingTabStrip:unspecified
     \--- LOCAL: android-support-v13.jar

I've looked at probably EVERY SO post on this problem and have tried it all, please help! Thank you!

Sakiboy
  • 7,252
  • 7
  • 52
  • 69
  • Please provide full build.gradle to see what is going there. – gio Dec 07 '14 at 21:53
  • Updated with my full build.gradle. – Sakiboy Dec 07 '14 at 22:01
  • 1
    Also please provide result of `gradlew androidDependencies` command at your project, it'll show structure of all dependencies at your project. – gio Dec 07 '14 at 22:20
  • possible duplicate of [Proguard fails with "can't write resource \[META-INF/MANIFEST.MF\] (Duplicate zip entry)"](http://stackoverflow.com/questions/16357959/proguard-fails-with-cant-write-resource-meta-inf-manifest-mf-duplicate-zip) – gio Dec 07 '14 at 22:39
  • @gio - I've tried everything in that post several times... But I guess I'll try them again... – Sakiboy Dec 07 '14 at 22:40
  • 1
    Try to remove all `android-support-v13.jar` from libs and add `compile 'com.android.support:support-v13:21.0.2'`instead – gio Dec 07 '14 at 22:46
  • @gio - I tried that and got it to compile after tinkering with it a little more. Thanks for the help. This an old project I'm working on and the owner is reluctant to update the libraries... :/ – Sakiboy Dec 08 '14 at 18:10

1 Answers1

1

In the Gradle build system, please don't include the support library by linking in its jar directly. Gradle has a better way of dealing with these dependencies that will prevent problems with duplications of classes as you're seeing here.

Include a support-v13 dependency via this statement in your dependencies block:

compile 'com.android.support:support-v13:21.0.2'

where you use the appropriate version number based on what you have installed via your SDK manager. If you add the dependency via Project Structure > (your module) > Dependencies > + > Library dependency, it should help you get it correct.

Scott Barta
  • 79,344
  • 24
  • 180
  • 163
  • I definitely agree! This project is a couple years old (as you can tell from the old libs) and the owner of it is really reluctant to update the libraries and even use Gradle dependencies... :/ and yes update the `support-v13` to `compile 'com.android.support:supprt-v13:21.0.2` helped solve the problem. – Sakiboy Dec 08 '14 at 18:12