Annotation-specified bean name 'b' for bean

I am using proguard 7.4.2. I used it successfully about a month ago but today when I ran it, it gave me a jar that gives a runtime error:

Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'b' for bean class [xxx.xxx.a.b] conflicts with existing, non-compatible bean definition of same name and class [xxx.xxx.b]

I inspected the code and saw this:

package xxx.xxx;

import xxx.xxx.a.b;
import org.springframework.stereotype.Component;

@Component
public class b {
  
  private final b dP;
  
  public b(b paramb) {
    this.dP = paramb;
  }
}

This code will not even compile. What does

private final b dP

refer to? Is it a self-reference to xxx.xxx.b or a reference to xxx.xxx.a.b? Its an ambiguous reference. Earlier when I ran proguard I had gotten this:

package xxx.xxx;

import xxx.xxx.a.i;
import org.springframework.stereotype.Component;

@Component
public class b {
  
  private final i dP;
  
  public b(i paramb) {
    this.dP = paramb;
  }
}

I haven’t changed the proguard config so not sure why its behaving differently this time. Any idea how I can fix this except using keep class? I do want the class to be obfuscated just that it should not mix up the names.

related (unresolved): I'm using proguard. I wanna know an option that keeps different class names for different packages

Hello,

What may be helpful to resolve this error is a custom obfuscation dictionary. ProGuard allows you to control the renaming process during obfuscation through the -obfuscationdictionary option. Here’s how you can use this option. First create a dictionary file (dictionary.txt) with unique names listed sequentially as seen below:

a
s
d
o
f
Ӏ
q
e
...

Then specify this file in your ProGuard configuration using the -obfuscationdictionary option.

# Apply custom obfuscation dictionary
-obfuscationdictionary /path/to/dictionary.txt

ProGuard will then apply the names from your dictionary in the order they appear, ensuring that each class, method, and field gets a unique name, avoiding the naming conflicts that are causing your runtime error. This approach allows you to maintain obfuscation while preventing the naming conflicts. Please see the ProGuard manual for more information on the obfuscation dictionary.

Best Regards,

Aissa

1 Like