Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProGuard - unexpectedly contains class

While I'm trying to obfuscate simple DataLoader.class file in ProGuard I get this error:

Reading program directory [C:\Users\uzytkownik\Documents\NetBeansProjects\ProTest\build\classes\Files\DataLoader.class]
Warning: class [DataLoader.class] unexpectedly contains class [Files.DataLoader]
Warning: there were 1 classes in incorrectly named files.
         You should make sure all file names correspond to their class names.
         The directory hierarchies must correspond to the package hierarchies.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)
         If you don't mind the mentioned classes not being written out,
         you could try your luck using the '-ignorewarnings' option.
Please correct the above warnings first.

Here is the project: http://www49.zippyshare.com/v/14668241/file.html

I will be grateful for your help.

like image 367
Wicia Avatar asked May 31 '14 20:05

Wicia


People also ask

Why won't ProGuard accept my class definition?

The given class file contains a definition for the given class, but the directory name of the file doesn't correspond to the package name of the class. ProGuard will accept the class definition, but the current implementation will not write out the processed version. Please make sure your input classes are packaged correctly.

Where do I put class files in ProGuard?

Notably, class files that are in the WEB-INF/classes directory in a war should be packaged in a jar and put in the WEB-INF/lib directory. If ProGuard is not keeping the right classes or class members, make sure you are using fully qualified class names.

How many duplicate class definitions are there in ProGuard?

Warning: class unexpectedly contains class Note: duplicate definition of program class Note: there were 20 duplicate class definitions. (http://proguard. sourceforge. net/manual/troubleshooting. html#duplicateclass) Warning: there were 21 classes in incorrectly named files.

How does ProGuard obfuscate the code?

By default, ProGuard obfuscates the code: it assigns new short random names to classes and class members. It removes internal attributes that are only useful for debugging, such as source files names, variable names, and line numbers. Specifies to print the mapping from old names to new names for classes and class members that have been renamed.


2 Answers

Warning: class [META-INF/versions/9/module-info.class] unexpectedly contains class [module-info] 

This is the issue I had and I tried few options mentioned below:

  1. -keep class module-info
  2. -keepattributes Module*
  3. -dontwarn module-info

The option worked for me is 3.

Not sure why but it solves my problem and I am able to make the jar.

This issue comes when you upgrade something like I upgrade the spring-boot version and the project starts failing.

Please check the maven dependencies as well.

like image 65
Atul Avatar answered Sep 20 '22 07:09

Atul


With the options -injars and -libraryjars, you should specify the proper base directory (or jar) of your classes, just like a classpath. In this case: classes, not classes\Files\DataLoader.class.

See the ProGuard manual > Troubleshooting > Warning: class file ... unexpectedly contains class ...

like image 38
Eric Lafortune Avatar answered Sep 19 '22 07:09

Eric Lafortune