使用ProGuard后,jar不会运行

时间:2016-07-09 09:29:39

标签: java proguard

我在jar文件中有app。我试着用ProGuard对它进行篡改。在我的ProGuard配置文件中,我添加了:

-keep public class forms.Login{
    public static void main(java.lang.String[]);
}

在obfustication映射文件后显示:forms.Login - > forms.Login:... void main(java.lang.String []) - >主...

我运行我的应用程序java -cp pathToObfusticatedJar.jar forms.Login,但是我收到错误:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Expecting a stackmap frame at branch target 52
Exception Details:
  Location:
    forms/Login.main([Ljava/lang/String;)V @0: invokestatic
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: b800 904c 2bbe 3d03 3e1d 1ca2 0026 2b1d
    0x0000010: 323a 0412 0619 04b6 0093 b600 6499 000e
    0x0000020: 1904 b600 92b8 0091 a700 0984 0301 a7ff
    0x0000030: dba7 0050 4c12 0db6 0061 b800 68b2 003f
    0x0000040: 012b b600 69a7 003c 4c12 0db6 0061 b800
    0x0000050: 68b2 003f 012b b600 69a7 0028 4c12 0db6
    0x0000060: 0061 b800 68b2 003f 012b b600 69a7 0014
    0x0000070: 4c12 0db6 0061 b800 68b2 003f 012b b600
    0x0000080: 69bb 0013 59b7 005a b800 5fb1
  Exception Handler Table:
    bci [0, 49] => handler: 52
    bci [0, 49] => handler: 72
    bci [0, 49] => handler: 92
    bci [0, 49] => handler: 112

        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetMethodRecursive(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

有人可以如此善意地解释我做错了什么吗?我是否必须更改proguard配置或以某种方式在cmd中设置main方法? 另外,我相信我已经设置了保持我的public static void main方法,但Proguard对此进行了修改。为什么?如何使它保持不变?

1 个答案:

答案 0 :(得分:1)

在Java 7 +上运行java应用程序时,您似乎已禁用preverification

检查您的配置并移除-dontpreverify