我试图用“com.github.sarxos”中的外部库“webcam-capture”来模糊一个simlpe java应用程序
我导入了一个类
import com.github.sarxos.webcam.Webcam;
在应用程序中调用方法
Webcam webcam = Webcam.getDefault();
没有混淆一切都运行良好,但在混淆jar后我遇到了运行时错误:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/github/sarxos/webcam/Webcamat
mdr.apmik.a.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)....
这是来自我的pom.xml的proguard-maven-plugin。我已经设置了跳过com.github.sarxos.webcam类混淆的选项,但没有成功。
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.8</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>proguard</goal></goals>
<configuration>
<injar>${project.build.finalName}-jar-with-dependencies.jar</injar>
<proguardVersion>5.2</proguardVersion>
<options>
<option>-allowaccessmodification</option>
<option>-dontoptimize</option>
<option>-dontshrink</option>
<option>-dontnote</option>
<!-- <option>-dontwarn</option> added option to ignore com.sun missing classes -->
<option>-keepattributes Signature</option>
<option>-adaptclassstrings</option>
<option>-keep public class mdr.apmik.App { public *; public static *; }</option>
<!-- Exclude external lib -->
<option>-keep class com.github.sarxos.webcam.** { *; } </option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</configuration>
</execution>
</executions>
我的问题是 - 是否可以将Proguard与这样的库一起使用? 如果是的话,如何为此配置Proguard?