Proguard-Can';找不到公共超类/java.lang.VerifyError

Proguard-Can';找不到公共超类/java.lang.VerifyError,java,proguard,Java,Proguard,我们正在开发一个桌面应用程序。使用以下配置标志在代码上运行ProGuard(版本5.3.3)时: -dontoptimize -allowaccessmodification -dontusemixedcaseclassnames -dontwarn Proguard给出了以下错误: Unexpected error while performing partial evaluation: Class = [com/code/backend/e/b/b] Method

我们正在开发一个桌面应用程序。使用以下配置标志在代码上运行ProGuard(版本5.3.3)时:

-dontoptimize
-allowaccessmodification
-dontusemixedcaseclassnames
-dontwarn
Proguard给出了以下错误:

Unexpected error while performing partial evaluation:
  Class       = [com/code/backend/e/b/b]
  Method      = [b(Ljava/lang/String;)Ljava/nio/file/Path;]
  Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/common/collect/ImmutableList] (with 2 known super classes) and [com/google/common/collect/UnmodifiableIterator] (with 1 known super classes))
Unexpected error while preverifying:
  Class       = [com/code/backend/e/b/b]
  Method      = [b(Ljava/lang/String;)Ljava/nio/file/Path;]
  Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/common/collect/ImmutableList] (with 2 known super classes) and [com/google/common/collect/UnmodifiableIterator] (with 1 known super classes))


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task 'proguard'.
> Can't find common super class of [com/google/common/collect/ImmutableList] (with 2 known super classes) and [com/google/common/collect/UnmodifiableIterator] (with 1 known super classes)
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 11
Exception Details:
  Location:
    com/code/code2/MainWindow.b(Lcom/code/code2/ClientAPIProtos$SoftwareStatus;)V @1: ifnull
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 2bc6 000a 2ab4 00bc c700 04b1 2bb2 00a4
    0x0000010: a500 0a2b b800 f599 0018 2ab4 00bc b601
    0x0000020: 9299 0020 2ab4 00bc 03b6 0193 a700 152a
    0x0000030: b400 bcb6 0192 9a00 0b2a b400 bc04 b601
    0x0000040: 932b b800 f699 0012 1225 4db8 0138 4e2a
    0x0000050: 04b5 00c8 a700 0f12 1e4d b801 3a4e 2a03
    0x0000060: b500 c82a b400 bcb6 0191 3a04 1904 c600
    0x0000070: 0c2c 1904 b601 799a 000b 2ab4 00bc 2cb6
    0x0000080: 0195 2ab4 00bc b601 903a 0519 05c6 0009
    0x0000090: 2d19 05a5 000b 2ab4 00bc 2db6 0194 b1  

    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
如果在配置中添加标志-dontpreverify,则生成将成功。但是,在运行jar文件时,我们会出现以下错误:

Unexpected error while performing partial evaluation:
  Class       = [com/code/backend/e/b/b]
  Method      = [b(Ljava/lang/String;)Ljava/nio/file/Path;]
  Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/common/collect/ImmutableList] (with 2 known super classes) and [com/google/common/collect/UnmodifiableIterator] (with 1 known super classes))
Unexpected error while preverifying:
  Class       = [com/code/backend/e/b/b]
  Method      = [b(Ljava/lang/String;)Ljava/nio/file/Path;]
  Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/common/collect/ImmutableList] (with 2 known super classes) and [com/google/common/collect/UnmodifiableIterator] (with 1 known super classes))


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task 'proguard'.
> Can't find common super class of [com/google/common/collect/ImmutableList] (with 2 known super classes) and [com/google/common/collect/UnmodifiableIterator] (with 1 known super classes)
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 11
Exception Details:
  Location:
    com/code/code2/MainWindow.b(Lcom/code/code2/ClientAPIProtos$SoftwareStatus;)V @1: ifnull
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 2bc6 000a 2ab4 00bc c700 04b1 2bb2 00a4
    0x0000010: a500 0a2b b800 f599 0018 2ab4 00bc b601
    0x0000020: 9299 0020 2ab4 00bc 03b6 0193 a700 152a
    0x0000030: b400 bcb6 0192 9a00 0b2a b400 bc04 b601
    0x0000040: 932b b800 f699 0012 1225 4db8 0138 4e2a
    0x0000050: 04b5 00c8 a700 0f12 1e4d b801 3a4e 2a03
    0x0000060: b500 c82a b400 bcb6 0191 3a04 1904 c600
    0x0000070: 0c2c 1904 b601 799a 000b 2ab4 00bc 2cb6
    0x0000080: 0195 2ab4 00bc b601 903a 0519 05c6 0009
    0x0000090: 2d19 05a5 000b 2ab4 00bc 2db6 0194 b1  

    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
这可以通过使用JVM标志-noverify来避免。阅读线程:

如果可能,我们希望避免这些“无验证”标志

注意:即使在添加时也会发生生成错误

-dontobfuscate
-dontshrink

初始化、验证和确认是建筑项目的一部分。我相信flag
-allowaccessmodification
允许在构建项目时进行修改(即从原始结构修改类)。当原始类结构被修改时,它们的堆栈帧就会受到干扰。这会导致验证失败。如果要忽略验证错误,则如上所述,需要使用暂停验证的标志

您正在指定抑制有关未解析引用的警告的选项。这可能导致处理代码时出现问题。ProGuard需要这些参考,例如在预验证步骤中。该错误确实表明输入不包含所有必要的依赖项:缺少
ImmutableList
UnmodifiableIterator
的一些公共超类或接口。对于桌面应用程序,应检查是否指定了包含所有必要类的Java运行时jar:

-libraryjars <java.home>/lib/rt.jar
-libraryjars/lib/rt.jar
请参阅ProGuard手册>故障排除>

ProGuard可能会打印一些注释和非致命警告:

注意:找不到动态引用的类 ProGuard找不到代码通过内省访问的类或接口。您应该检查是否要添加包含此类的jar

注:。。。调用“(…)Class.forName(variable).newInstance()” ProGuard列出了动态创建的类实例的所有类强制转换,如“(MyClass)class.forName(variable).newInstance()”。根据您的应用程序,您可能需要使用类似于
-keep class MyClass
的选项保留上述类,或者使用类似于
-keep class*的选项保留它们的实现实现MyClass
。您可以通过指定
-dontnote
选项来关闭这些注释

注:。。。动态访问字段/方法“…” ProGuard列出了许多构造,如“.getField”(“myField”)”。根据您的应用程序,您可能需要找出所提到的类成员的定义位置,并使用类似于
-keep class MyClass{MyFieldType myField;}
的选项保留它们。否则,ProGuard可能会删除或混淆类成员,因为它无法知道它们到底是哪些成员。它确实列出了可能的候选人,供您参考。您可以通过指定
-dontnote
选项来关闭这些注释。

作为最终解决方案,您可以关闭优化(-dontoptimize)和预验证(-dontpreverify)