我从命令行使用ProGuard:
java -jar $PRO_GUARD_HOME/proguard.jar @proguard-rules.pro > usage.log
这是我的proguard-rules.pro
规则文件:
-injars build/libs/test-main-1.0.jar
-libraryjars /System/Library/Frameworks/JavaVM.framework/Classes/classes.jar
-dontoptimize
-dontobfuscate
-dontpreverify
-printusage
-dontnote
-keep public class com.foo.app.Main {
public static void main(java.lang.String[]);
}
-keepclassmembers class * {
static final % *;
static final java.lang.String *;
}
当我运行上面的命令时,我得到以下错误:
Error: The output jar is empty. Did you specify the proper '-keep' options?
如何解决这个错误?
不要收缩库文件。
# Keep - Library. Keep all public and protected classes, fields, and methods.
-keep public class * {
public protected <fields>;
public protected <methods>;
}