我在处理 ProGuard 和 Android 时遇到问题。
我在网上搜索了几个小时,发现了多种混淆 Android 应用程序的方法。现在我正在尝试一种看起来最简单的方法,所以:
- 我在
config.cfg
项目的根目录中创建了一个文件- 我
proguard.config=config.cfg
在我的project.properties
- 我使用 Eclipse 导出向导导出并签署 .apk 文件
我Proguard returned with error code 1. See console
在控制台中收到一条消息:
Proguard returned with error code 1. See console
Note: there were 3847 duplicate class definitions.
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
You should check if you need to specify additional program jars.
Warning: there were 4 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Error: Please correct the above warnings first.
即使我使用 Proguard 官方网站提供的配置或默认配置,我也会有错误。
这是我的自定义配置(myProject/config.cfg):
-injars bin/classes
-injars libs
-libraryjars "C:\Program Files\Android\android-sdk\platforms\android-13\android.jar"
-dontskipnonpubliclibraryclasses
-optimizationpasses 5
-printmapping map.txt
-flattenpackagehierarchy
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-keep public class * extends android.app.Application
-keep public class * extends android.app.Activity
-keep public class * extends android.app.PreferenceActivity
-keep public class * extends android.view.View
-keep public class * extends android.widget.BaseAdapter
-keep public class * implements android.view.View.OnTouchListener
-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);
}
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
我无法让它工作......任何想法将不胜感激!
注意:libs
我使用存储在我的项目文件夹中的 Jackson JSON 库