简体   繁体   中英

How to reduce Java ME application size?

Working with Java ME I encountered the following problem:

All classes (including anonymous) in project transforms into separated files after the project building. This leads to an increase of application size as each individual file is not less than 1 kilobyte in the assembled package.

This problem is especially critical in J2ME where the application size is so critical.

My questions are:

  1. Is there a way to get around this problem?
  2. Is it possible to use the specific method for reducing the size of the application?

Which devices are you targeting? This used to be a problem on legacy devices years ago, but unless your MIDlet is really huge you shouldn't have too much of a problem these days. Have you actually encountered an issue, or are you seeking advice on how to prevent it in future?

You can obfuscate and reduce compiled class sizes using Proguard .

So Proguard did a good job already cutting 300K from you final Jar file. Can it do more? Maybe. What settings did you use? I always go with at least:

  • defaultpackage="", all obfuscated classes are moved to the default package
  • overloadaggressively="true", multiple fields and methods can get the same names, as long as their arguments and return types are different
  • optimizationpasses="3", number of optimization passes to be performed. This may vary from one application to another. Check the final jar size, when it does not shrink any further, stop incresing this value.
But it is very unlikely that your jar file drops to the desired 256kb you need only with proguard.

When you say that your media files are already compressed, did you use something like PNGGauntlet before adding them to lwuit?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM