1

I'm wondering if someone can tell me how to obfuscate a single file, or maybe just two files, inside a jar file using proguard. I'm hoping that keeping every single class but the one i want to obfuscate isn't my only option, where as that takes a ton of time and is very tedious.. So, Is it possible to only obfuscate a single class? If so, how.. Thanks in advance!

Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276
Nathan F.
  • 3,250
  • 3
  • 35
  • 69
  • I don't see why obfuscating all your .java files would be a performance issue, unless we are talking in the scale of millions of files. – asgs Jan 11 '13 at 18:46
  • Not a performance issue, some sort of access isue. The jar is accessed from another, I was able to make it ignore the one class needed to open it (The jar i'm obfuscated, I didn't develop. Just modified) so, it's able to start the obfuscated jar. But then it has an issue where it just crashes.. no report, no nothing. And, there are about 900 class files. So, I want to make proguard ignore ever class EXCEPT the ones that i absolutely need obfuscated.. – Nathan F. Jan 11 '13 at 18:55
  • Any exceptions thrown or logged as part of log files or console logs shouldn't get affected by the Obfuscation. If so, that's a serious issue. But yes, I'd tend to go obfuscate the files that are really required. – asgs Jan 11 '13 at 19:01
  • How do i go about obfuscating only my files.. there are 8 files that absolutely NEED to be obfuscated.. – Nathan F. Jan 11 '13 at 19:23

2 Answers2

1

Obfuscating a single class is generally not very useful: it will be easy to find and easy to reverse-engineer, since other classes and references to them remain readable. ProGuard therefore obfuscates all classes (except the specified ones) by default.

That being said, this should work:

-keep class !mypackage.MySecretClass, !mypackage.MyOtherSecretClass {
    *;
}

It preserves the class/field/method names of all classes except the specified one. In other words, it only obfuscates the specied classes.

Eric Lafortune
  • 45,150
  • 8
  • 114
  • 106
0

You can exclude all the items except the ones you want to obfuscate; see How to keep/exclude a particular package path when using proguard?

If that doesn't seem practical, a workaround would be to package the files you want to obfuscate in their own jarfile, run ProGuard, then repackage those files with the other files you want to include in a new jarfile.

Community
  • 1
  • 1
rob
  • 6,147
  • 2
  • 37
  • 56