Java 混淆 - 使用 proguard

Java Obfuscation - with proguard

我正在使用 oshi 在我的应用程序中创建唯一密钥。我从项目中创建了一个带有 maven 阴影插件的胖罐子。 fat jar 工作正常,没有混淆。但是,如果我使用 ProGuard 对 jar 进行混淆处理,则 jar 在尝试 运行.

时会抛出以下错误
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.a.H.h()Ljava/lang/String;
    at com.sun.a.H.h(Native Method)
    at com.sun.a.H.<clinit>(Unknown Source)
    at com.sun.a.ab.setAlignType(Unknown Source)
    at com.sun.a.ab.<init>(Unknown Source)
    at com.sun.a.ab.<init>(Unknown Source)
    at com.sun.a.ab.<init>(Unknown Source)
    at com.sun.a.ab.<init>(Unknown Source)
    at com.sun.a.b.d.aJ.<init>(Unknown Source)
    at com.sun.a.b.d.X.a(Unknown Source)
    at oshi.hardware.platform.windows.WindowsCentralProcessor.initProcessorCounts(Unknown Source)
    at oshi.hardware.common.AbstractCentralProcessor.<init>(Unknown Source)
    at oshi.hardware.platform.windows.WindowsCentralProcessor.<init>(Unknown Source)
    at oshi.hardware.platform.windows.WindowsHardwareAbstractionLayer.createProcessor(Unknown Source)
    at oshi.util.Memoizer.get(Unknown Source)
    at oshi.hardware.common.AbstractHardwareAbstractionLayer.getProcessor(Unknown Source)
    at com.pegado.qpguard.f.d.a(Unknown Source)
    at com.pegado.qpguard.d.b.<clinit>(Unknown Source)
    at com.pegado.qpguard.editor.Application.main(Unknown Source)

所以我创建了一个 proguard.confile 来管理混淆规则。

-keep public class com.acme.qpguard.editor.Application { *; }
-keep class org.apache.log4j.** { *; }
-keep class oshi.hardware.** { *; }
-keep class oshi.util.** { *; }
-keep class oshi.software.** { *; }
-keep class oshi.SystemInfo { *; }

但这对我没有帮助。罐子仍在抛出 java.lang.UnsatisfiedLinkError,由 oshi 引起。 期待解决此问题的指示。提前致谢。

我已将 proguard.conf 修改为:

-dontskipnonpubliclibraryclassmembers
-keepdirectories
-target 1.8
-forceprocessing
-dontoptimize
-allowaccessmodification
#-overloadaggressively
#-keeppackagenames org.**
-keepattributes *Annotation*
-verbose
-keep public class com.acme.qpguard.editor.Application { *; }
-keep class org.apache.logging.log4j.** { *; }
-keepattributes Signature,Annotation
-keep class org.sqlite.** { *; }
-keep class com.sun.** { *; }
-keep class com.google.** { *; }
-keep class oshi.** { *; }
-keep class com.acme.qpguard.logger.LoggerConstants { *; }
-keepclassmembers class com.acme.qpguard.logger.QPLogger {
    QPLogger commonLoggerInstance;
}
-keep class com.acme.qpguard.logger.QPLogger { *; }
#
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keepattributes SourceFile,LineNumberTable
-dontwarn

# absolutely must keep this commented out for production
# -keepattributes SourceFile,LineNumberTable

这可能需要进一步优化甚至更正,但暂时对我有用。谢谢