混淆首选项
混淆首选项控制对包进行混淆的过程。 EclipseME使用Proguard 来完成混淆过程。
首选项项目:
项目 | 内容 |
Proguard Root Directory | 在这里你可以指定Proguard安装路径。 如果你要对你的程序混淆,必须安装Proguard。 |
Use Specified Arguments | 默认情况下, EclipseME会使用如下参数来调用Proguard进行混淆:-dontusemixedcaseclassnames -dontnote -defaultpackage '' 在某些场合你需要指定不同的参数时, 可以将"Use specified arguments"(使用指定参数) 这个选项选中并且在文本框里填上参数。 Microsoft Windows 用户特别注意: 默认情况下, ProGuard假定你使用的操作系统会区分文件名中的大小写。 (比如 A.java 和 a.java 是两个不同的文件)很明显,Microsoft Windows不是这样的操作系统。 Windows用户要确定为ProGuard指定了- dontusemixedcaseclassnames 选项。 如果你没有这样做,而你的工程文件又超过了26个类的话, ProGuard默认 使用变换大小写的方式为混淆后的类命名。显然这会覆盖原来的类。 安全起见,从EclipseME 0.9.0发行版开始 -dontusemixedcaseclassnames 选项被包含到了传给 ProGuard的默认选项中去。 如果你是*NIX用户并且你的工程中的类超过26个的话, 去掉该选项你可以得到一个稍微小点的JAR文件。 |
Proguard Keep Expressions | 在这里你可以设置一个表达式是的某些类不被混淆。表达式中用到的关键字 请参阅Proguard文档。 默认的表达式会保留所有的MIElet类以及他们的方法不被混淆。 |
回头看看Proguard的配置资料
http://proguard.sourceforge.net/
JME Wireless Toolkit Integration
ProGuard can be seamlessly integrated in Sun's Wireless Toolkit (WTK) for Java Micro Edition (JME).
The WTK already comes with a plug-in for ProGuard. Alternatively, ProGuard offers its own plug-in. This latter implementation is recommended, as it more up to date and it solves some problems. It is also somewhat more efficient, invoking the ProGuard engine directly, instead of writing out a configuration file and running ProGuard in a separate virtual machine.
In order to integrate this plug-in in the toolkit, you'll have to put the following lines in the file {j2mewtk.dir}/wtklib/Linux/ktools.properties
or {j2mewtk.dir}/wtklib/Windows/ktools.properties
(whichever is applicable).
obfuscator.runner.class.name: proguard.wtk.ProGuardObfuscator
obfuscator.runner.classpath: /usr/local/java/proguard/lib/proguard.jar
Please make sure the class path is set correctly for your system.
Once ProGuard has been set up, you can apply it to your projects as part of the build process. The build process is started from the WTK menu bar:
Project -> Package -> Create Obfuscated Package
This option will compile, shrink, obfuscate, verify, and install your midlets for testing.
Should you ever need to customize your ProGuard configuration for the JME WTK, you can adapt the configuration file proguard/wtk/default.pro
that's inside the proguard.jar
.