将 ProGuard 与 Android 配合使用
2022-09-01 22:51:41
我在处理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>;
}
我无法让它工作...任何想法将不胜感激!
注意:我使用存储在项目文件夹中的 Jackson JSON 语言库libs