1

I'm obfuscating an executable jar using ProGuard version 5.3.3.

My jar contains other libraries which I do not want to obfuscate or optimize.

This is my ProGuard config:

-libraryjars 'C:\Program Files\Java\jre1.8.0_131\lib\rt.jar'

-injars myjar-debug.jar
-outjars myjar-release.jar

-skipnonpubliclibraryclasses
-dontoptimize
-dontshrink
-useuniqueclassmembernames
-keeppackagenames org.**
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
-ignorewarnings

-keep class org.** { *; }
-keepclassmembers class org.** { *; }
-dontwarn org.**

-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

-keepclasseswithmembers class * {
    native <methods>;
}

-keepclasseswithmembernames class * {
    native <methods>;
}

The obfuscation works perfectly fine and there are no errors in executing the jar. However, if I compare the original jar and the obfuscated jar, I can see that ProGuard has modified classes within package org.**. Most of the class files size is more than the original size.

Original Jar(Left) VS Obfuscated Jar(Right)

I don't want ProGuard to modify these files at all. How can I completely exclude this package so that the binary of the class files in org.** are exactly same?

PC.
  • 6,870
  • 5
  • 36
  • 71

1 Answers1

0

I think you need to tweak your jar building process, and obfuscate first then make executable jar.

I am not sure if you are using maven/gradle however this will make your life easy compared to using command line

Shailesh Chandra
  • 2,164
  • 2
  • 17
  • 25
  • does it matter how the jar is created? – PC. Dec 28 '17 at 12:55
  • for some extent yes, in your case if you obfuscate first before creating a fat(executable) jar, which means your jar is only containing the source code, subsequently the process of creating executable jar will bundle dependencies. – Shailesh Chandra Dec 28 '17 at 13:15