ProGuard JNI错误 [英] ProGuard JNI Error

查看:79
本文介绍了ProGuard JNI错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ProGuard 来模糊我的Java桌面应用程序.当我启动模糊的JAR时,出现以下错误:

I'm using ProGuard to obfuscate my Java Desktop application. When I launch the obfuscated JAR, I'm getting the following error:

> java -jar program.jar
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 80
Exception Details:
  Location:
    MyMainClass.a(Ljava/lang/String;)Ljava/lang/String; @40: iflt
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 0406 7805 0882 8206 0882 0778 0482 0659
    0x0000010: 7808 822a b600 0f59 bc05 0459 585f 0464
    0x0000020: 5b3e 4c36 045b 583d 9b00 282b 2a1d 5ab6
    0x0000030: 000e 8403 ff1c 8292 551d 9b00 162b 2a1d
    0x0000040: 8403 ff5a b600 0e15 0482 9255 1da7 ffdb
    0x0000050: bb00 0659 2bb7 000d b0

        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)

我在我的项目中使用以下 Maven 依赖项:

I'm using the following Maven dependencies in my project:

<dependencies>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>com.github.dblock</groupId>
        <artifactId>oshi-core</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>net.lingala.zip4j</groupId>
        <artifactId>zip4j</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-nop</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>com.google.jimfs</groupId>
        <artifactId>jimfs</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>org.softsmithy.lib</groupId>
        <artifactId>softsmithy-lib-core</artifactId>
        <version>LATEST</version>
    </dependency>
</dependencies>

我的ProGuard配置文件也如下所示:

Also my ProGuard configuration file looks as follows:

-microedition
-dontskipnonpubliclibraryclassmembers
-keepdirectories
-target 1.8
-forceprocessing
-dontoptimize
-allowaccessmodification
-overloadaggressively
-keeppackagenames org.**
-dontpreverify
-verbose
-dontwarn **.**


-keep class org.sqlite.** {
    <fields>;
    <methods>;
}

-keep class com.sun.** {
    <fields>;
    <methods>;
}

-keep class com.google.** {
    <fields>;
    <methods>;
}

-keep class oshi.** {
    <fields>;
    <methods>;
}

# Rest omitted

我尝试禁用优化,预验证,缩小,混淆以及还删除了-target 1.8标志.只有这样,错误才会消失.

I tried disabling optimization, preverification, shrinking, obfuscation and also removing the -target 1.8 flag. Only then the error go away.

但是我想保留所有选项,并且不要破坏输出JAR,否则毫无意义.我该怎么办?

But I would like to keep all options and not break the output JAR otherwise it's pointless. How do I do that?

推荐答案

您正在构建桌面应用程序,因此需要禁用以下选项:

You are building a Desktop application, thus you need to disable the following option:

-microedition

此外,Java 7+版需要进行预验证,因此您还需要禁用:

Additionally, preverification is needed for Java versions 7+, thus you also need to disable:

-dontpreverify

-target 1.8也可以省略.

这篇关于ProGuard JNI错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆