Optimization for smaller .cod file (.jar)

The RIM compiler performs additional optimization and compression in the resulting ".jar" when creating the final .cod file, but developers can do a lot to significantly reduce the final size of the .cod file.

One such thing is to run PNGCrush , OptiPNG, or a similar tool to reduce the size of the included .png files. In an application with a large number of image files (for example, a user interface application), this can lead to a significant reduction in the final size of the .cod file.

Do you have any tips on optimizing the final .cod file for size? Is there something you need to do in the .java code itself? Is there something you need to do in the project structure? Do something with files or resources?

Thanks!

+4
source share
4 answers

Good question!

  • Compression ( GZip , ZLib ) can be useful when installing large bin / txt / xml files

And what they say in RIM:

In addition, interesting facts :

All images were in PNG format. I want to know why: compile with JDE 4.5 β†’ 900k, compile JDE 4.2, 2.6.1, 4.7 β†’ 1800K. What is the difference? Thank you


JDE 4.5 seems to use more optimization methods than the older JDE version.


Look at the image below, it is created by PngOut from 55 K png images. Its size is 3427 bytes.

+3
source

I think that you definitely want to consider compression (and the optimizer / obfuscator), for example, ProGuard ( http://sourceforge.net/projects/proguard/ ). This can reduce your Java code by folding class names into abridged versions, removing unused code, etc. Along the way, this can improve code efficiency. It's great. The only tricky part is modifying your assembly to optimize the generated class files before the RIM assembly material gets it to make .cod.

+2
source

GZIP is a good approach for all resources, and then use the net.rim.device.api.compress.GZIPInputStream class to download compressed files. Thus, you do not need to unpack the code yourself.

You can also use pngout to optimize image resources.

+1
source

Make sure you use PNG-8 instead of PNG-24 whenever possible. Try to minimize the number of colors in the palette. After that use PngOut.

As for ProGuard, I am having problems with older BB devices when using the optimization binding of the Progruard switch ("-dontoptimize"), so use it carefully, although this is a great tool.

+1
source

All Articles