Eclipser
Eclipser

Reputation: 23

How to use the GUI of Proguard? Problems with keeping the right classes from being obfuscated

I use Eclipse to make my Java projects. Now I have made a calculator and exported it as a runnable jar file. This calculator has been checked by a teacher and it is working. I can post the complete code but it wouldn't make sense for you to see it.

Now I tried to obfuscate the .jar file. I have downloaded proguard 5.0 beta 2 to do this. In the directory lib, there is a file called proguardgui.jar. I use this jar file to process my files.

As long as I don't use one of the options: optimization, shrinking or obfuscation, the output file will run and show me my calculator.But as soon as I want to use one of those options of proguard(optimization, shrinking or obfuscation), the output file isn't running anymore.

The main method is in cal.SwingCalculator so I added cal.SwingCalculator to keep additional class names and class member names. But still it doesn't work. ( I have added the cal.SwingCalculator to the bottom of the screen in optimization, shrinking and obfuscation)

For example when I only use obfuscation, the output file will still change the name of the main method. I had used a Java decompiler to check the result.

How is it possible that the outputfile isn't working?

And when I add the class names that need to be kept, do I need to check all the boxes under the tab access with required on it or is it ok to set it to don't care?

I did everything that was mentioned in this video: https://www.youtube.com/watch?v=vTgWPiRUCu4

# package cal; 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

class SwingCalculator {
 public static void main(String[] args) {
 JFrame frame = new Calculator();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);
  }
}

And a part of the other class :

package cal;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

class Calculator extends JFrame {Lots of code}

Upvotes: 2

Views: 5506

Answers (1)

Eric Lafortune
Eric Lafortune

Reputation: 45648

Since you have a traditional Java application with a main method, you need to make sure this checkbox in the ProGuard GUI is ticked:

(tab) Shrinking > (panel) Keep > (checkbox) Applications

It keeps all classes that have main methods, along with the main methods themselves.

Upvotes: 1

Related Questions