Search code examples
javaobfuscationproguardembedded-resource

Using ProGuard to obfuscate resource filenames


I have an application JAR file I would like to obfuscate using ProGuard. It contains a number of PNG files that are referenced using path strings in the application, such as /my/path/image.png.

I tried using the -adaptresourcefilenames **.png resource obfuscation option but it didn't seem to have any effect.

Can ProGuard rename my PNG files somehow? I need it to rename the files and change the strings in class files that reference it.


Solution

  • The option -adaptresourcefilenames only works for resource files like mypackage/MyClass.properties that have a corresponding class file mypackage/MyClass.class. If the class name is obfuscated the resource file name is obfuscated along.

    ProGuard doesn't obfuscate other file names, since the names are often not specified as a single literal string in the code, making it difficult or impossible to replace them.