Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Shaving  (Read 3192 times)
0 Members and 1 Guest are viewing this topic.
Offline Matzon

JGO Knight

Medals: 19
Projects: 1

I'm gonna wring your pants!

« Posted 2003-12-18 05:08:18 »

In my quest for ever decreasing jar files I found one "simple" optimization which gave me a 10% decrease in file size!

I use antenna and proguard with my ant scripts. I use the wtkpackage task with preverify and obfuscation.

To make this optimization work, you need to give proguard two arguments:
<argument value="-defaultpackage ''"/>
<argument value="-overloadaggressively"/>

You will also need a -keep argument for the obfuscate task (previously done by the wtkpackage task)

<argument value="-keep public class my.package.MIDlet"/>

Unfortunatly you then have to use the wtkobfuscate task, since the wtkpackage doesn't accept arguments. And by using the obfuscate task, you manually need to preverify it :/

So, do a wtkpackage without preverify and obfuscation. then obfuscate and finish off with a preverify.

Offline mhnsp

Junior Newbie

Java games rock!

« Reply #1 - Posted 2003-12-18 13:40:37 »

One thing I've noticed - (and this may already be known to some/most here) - is that using local variables seems to decrease the size vs. using global variables.  For instance, I have a program that contains two methods which use two global variables for temporary purposes.  When I remove them and use two local pairs for the same purpose, my *.jar file shrunk by 20 bytes.  In both instances, I use ProGuard to shrink the file, also, so I'm not sure of the savings beforehand (if any).
Offline jeevan_gr

Junior Newbie

Java games rock!

« Reply #2 - Posted 2003-12-19 07:49:40 »


       pls let me details about his, can we implement it to all J2ME application. my usual application will be J2ME Games

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ribot

Junior Devvie

Ribot - mobile UI specialist

« Reply #3 - Posted 2005-08-02 16:23:50 »

I'm trying to use antenna and proguard and using wtkobfuscate and wtkpreverify in an attempt to package up my jars.  But I'm having troubles with the preverification part:

JAR file creation failed with error -1
The preverified classes if any are in tmp41.

The preverify part of my ant script looks as follows:

<wtkpreverify jadfile="game.jad" jarfile="game.jar" classpath="C:\" verbose="true" />

Whatever I do, the ant build seems to fail on the above line with the "JAR file creation failed with error -1...."

Any tips would be much appreciated. - design agency focused on mobile - online vintage eyewear store
Offline Abuse

JGO Ninja

Medals: 64

falling into the abyss of reality

« Reply #4 - Posted 2005-08-03 00:19:37 »

JAX'ing ontop of proguard is another incredibly quick and easy way to save another few Kb (~5%)

And - if you don't have to pass T-mobiles utterly ridiculous acceptance criteria - you can 7zip/kzip the jar to save another 10-15%.

pack all your asset files to reduce the zips table of contents, another 1-2% saving.

Write your code with size in mind - no hardcoded array allocations - minimal member variables, structure your classes so JAX can eliminate & merge them.

Do agressive color reduction on your images (but leave your images in 8bpp)
Match the images palette to the color model used by the phone you are targeting.
pngout/pngcrush all your image assets to remove any ancillery png chunks

etc etc etc

The list is endless.

w00h000, my 1000th post  Shocked Shocked Shocked
Offline shmoove

Junior Devvie


« Reply #5 - Posted 2005-08-03 07:52:03 »

Mind you, I remember running into a couple of phones that didn't like the 7zip-compressed jars and agressive obfuscation. A pair of Samsungs and an LG, but I can't recall the specific models. If you use these methods and your game misteriously doesn't work on a few phones, try without the added compression.

And while we're on the topic:
A tool that automates a lot of the image compression.
A thread with some nice information on saving jar space, especially through image manipulations.


Pages: [1]
  ignore  |  Print  

EgonOlsen (44 views)
2018-06-10 19:43:48

EgonOlsen (24 views)
2018-06-10 19:43:44

EgonOlsen (46 views)
2018-06-10 19:43:20

DesertCoockie (201 views)
2018-05-13 18:23:11

nelsongames (126 views)
2018-04-24 18:15:36

nelsongames (125 views)
2018-04-24 18:14:32

ivj94 (866 views)
2018-03-24 14:47:39

ivj94 (127 views)
2018-03-24 14:46:31

ivj94 (770 views)
2018-03-24 14:43:53

Solater (142 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!