views:

123

answers:

1

Hi,

Im trying to obfuscate a Java MIDlet with proguard. It runs ok on the PC, however, when I run it on the phone, the program opens, connects to the server, and then freezes. If I disable obfuscation, it runs ok again on the phone. Ive tryed all the obfuscation levels for apps (7, 8 and 9 at NetBeans), and none of them seems to work properly, and I cant release this app for comercial use without obfuscation. Also, the compiler throws some warnings:

Note: duplicate definition of library class [java.io.ByteArrayOutputStream]
Note: there were 14 duplicate class definitions.

But I dont know if this is realy the problem. Does anyone knows what is wrong? The obfuscator arguments are listed below:

Obfuscator Arguments (7):
    -dontusemixedcaseclassnames
    -default package ''
    -keep public class ** {
        public *;
    }

Obfuscator Arguments (8): same as (7) plus -overloadaggressively.

Obfuscator Arguments (9): same as (8) but
    -keep public class ** extends javax.microedition.midlet.MIDlet {
        public *;
    }
instead.

Thanks.

+1  A: 

Obfuscation can break stuff. Without potted example code it's hard to say exactly what might be wrong. An example of something that could go wrong is if you load a class in your code by name - the obfuscated class will have a different name, and hence will not be found.

The messages you mention could be indicative of the problem - you must have those classes more than once on your path. Is that class you mention pertinent to the connection you're having problems with? Look closely at the jars in use and ensure the the right (and minimum) set of classes are being included in your application. ByteArrayOutputStream in the CLDC is not the same as in the desktop JDK.

martin clayton
Yes, I know that without code is hard to find the problem, but I dont have any ideia what part of the code is causing this, as there are many classes in the system and I cant paste all of them here. Im showing olny the 2 last lines of the warnings, because the classes seems too much generic to give me a hint of where is the error, like: Note: duplicate definition of library class [javax.microedition.media.control.VolumeControl], and I dont even have sound or any kind of media in my app... Ill take a look if there is some kind of external call that may cause this, as you pointed, thanks.
eMgz
@eMgz - is it possible to boil the code down to a very short snippet that exhibits the same freeze? (Might help you home in on the issue, even if too much code to post.)
martin clayton
I dont thinks so, there are a lot of classes to handle the record store, connection, threads, images and so on, but Im trying to debug one by one using the -keep option. Thanks anyway.
eMgz
ok, for the record:http://proguard.sourceforge.net/manual/troubleshooting.html#runtimeThe problem was due to optimization. For some reason it was screwing up a thread that should invoke another screen, so, using -dontoptimize solves the problem.
eMgz