When you are deploying a Luciad portfolio-based application, you are required to obfuscate the Luciad portfolio libraries with ProGuard.
As this is an intricate process, you can already take some precautions to prevent potential glitches before you start obfuscating. If you still run into problems despite those precautions, you can find a couple of suggestions for solutions in this article as well.
Obfuscation is quite a complex process that involves re-writing the class files. We try to make the process as hassle-free as possible by shipping a tested sample ProGuard configuration for you to use.
By respecting these rules, you can prevent most obfuscation-related problems:
- Use the latest version of ProGuard.
ProGuard has its own set of issues and gets updated frequently. It is recommended to use the latest version.
- Use the ProGuard configuration files shipped with the product and version that you are using.
Those files are updated regularly. Using the files of another product, or of an older version, will likely result in errors.
- Follow the Maven ProGuard plugin configuration used in our Maven tutorial.
The Maven ProGuard plugin is very difficult to configure correctly. We recommend following the configuration used in our Maven tutorial. Alternatively, you can set up obfuscation as a separate step in your build pipeline and use ProGuard directly or through Ant.
- ProGuard does not support multi-release jars.
Multi-release jars were introduced in Java 9, but are not supported by ProGuard. If your application includes or depends on such jars, you must filter out the alternate versions or ProGuard will complain about duplicate definitions.
- Do not shrink or optimize your application.
Shrinking or optimizing your application causes ProGuard to remove what it considers unused code. It discards code too eagerly, however. Using these options in a LuciadLightspeed-based application will cause run-time errors such as
Check the solutions to some of the possible issues with ProGuard obfuscation.
Get more information
Do not use the
The log of warnings will also be of help if you still have to get in touch with the Luciad Support Desk Services.
You may have incorrectly split
Make sure that:
All Luciad JARs (the JARs with an
lcd_prefix) and your application JARs are marked as
All third-party JARs are marked as
jce.jarmust both be specified as
This is most likely caused by turning off the pre-verification option in ProGuard. As of Java 7, pre-verification is required or your application will not run.
Make sure that the
-dontpreverifyoption doesn’t appear anywhere in your ProGuard configuration.
Errors caused by ProGuard tend to be non-specific and can have various causes. Some of the most likely causes are listed here.
Possible cause: Mixing obfuscated and non-obfuscated versions of the same JAR(s).
Solution: Verify that the classpath only contains the obfuscated JARs.
Possible cause: ProGuard optimization is enabled.
Solution: ProGuard optimization occasionally causes problems. It’s recommended to disable it with
jce.jarwere not specified as
Solution: Make sure that both
This warning is thrown if you have incorrectly split your code into
libraryjars. Make sure that all Luciad jars (
lcd_*.jar) and your own code are specified as injar and other libraries as libraryjar.
Make sure that you have specified the necessary JDK jars (e.g.
rt.jar) and jmods as libraryjar. You might also have to include JavaFX jars.
You may be mixing obfuscated and non-obfuscated code. Make sure that your class path includes only obfuscated jars and has no reference to any of the original, non-obfuscated code. Take special care when using wildcards.
Before contacting the Luciad Support Desk Services, take a look at ProGuard’s troubleshooting page. If you encounter an unlisted problem that you are unable to solve, contact the Luciad Support Desk services and provide:
A detailed description of the problem, including any stack traces.
An explanation of the steps leading to the problem.
The ProGuard version you used.
Your ProGuard configuration files.
The full obfuscation log. Those are all the messages that ProGuard writes to the console.