ProGuard错误:输出jar为空。你有没有指定正确的' -keep'选择?

时间:2015-09-24 21:10:43

标签: java android proguard

我在命令行中使用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?

如何解决此错误?

1 个答案:

答案 0 :(得分:3)

不要缩小库文件。这对我有用;

    # Keep - Library. Keep all public and protected classes, fields, and methods.
-keep public class * {
    public protected <fields>;
    public protected <methods>;
}