I'm trying to use ProGuard with one of my applications, let's say A. This application includes another application as a library (let's say B). This is my proguard file.
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-injars bin/classes
-libraryjars lib
When I first executed it, I got the following error:
Proguard returned with error code 1. See console
[2012-01-05 12:18:55 - BSabadellHC-Entrega] Note: there were 1059 duplicate class definitions.
[2012-01-05 12:18:55 - BSabadellHC-Entrega] java.io.IOException: Can't write [/private/var/folders/19/321lw_654pzdqr8y34ysvsx80000gn/T/android_7971378611269030364.jar] (Can't read [/private/var/folders/19/321lw_654pzdqr8y34ysvsx80000gn/T/android_1457478862713006376.jar] (Duplicate zip entry [com/ideaknowing/labs/android/ikarengine/e.class == android_1457478862713006376.jar:com/ideaknowing/labs/android/ikarengine/R$anim.class]))
The relevant parts for me are:
- There are duplicate objects
- They should because of the R files. It is said by the console that there are duplicate resources in R$anim (of course, since both the application A and the library B are including animations, layouts and so on).
So my idea was obviously to exclude from ProGuard the R files, and for that I included the following lines of code:
-keep public class net.firsrproject.android.R
-keep public class com.ideaknowing.labs.android.ikarengine.R
Nevertheless, I still get the same error (so I guess the files are still being included in Proguard). Has anybody experience with removing R files from ProGuard? Is there any tip or suggestion on how can I get rid of this error?
Thanks, and regards