使用ProGuard和Android应用程序时,重复资源 [英] Duplicate resources when using ProGuard and an Android application
问题描述
我想搭配使用ProGuard和我的应用程序之一,让我们说A.此应用程序包括其他应用程序作为一个库(假设B)。这是我ProGuard的文件。
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:
- 有重复的对象
- 他们不应该因为R上的文件的。它是由控制台说,有在R $阿尼姆重复资源(当然,由于两个应用程序A和库B是包括动画,布局等)。
所以我的想法是很明显,从ProGuard的排除R上的文件,并为我包括code以下行:
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
尽管如此,我仍然得到同样的错误(所以我想仍然被列入Proguard的文件)。有从ProGuard的除去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?
谢谢,和问候
推荐答案
删除 -injars斌/班
如果您正在使用的Android库项目从类文件库中使用此选项(这为我工作结合这)处理两次。
Remove the -injars bin/classes
if you are using android library project as the class files from the library are processed twice with this option (This worked for me in combination with this).
如果上述不起作用尝试 -dontnote
选项。
If the above doesn't work try the -dontnote
option.
这篇关于使用ProGuard和Android应用程序时,重复资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!