Below is a topic we frequently receive questions about. We hope you find the response useful as well.
Annotation-specified bean name ‘b’ for bean
User 1 - Jun 2024
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.
Tag(s):
ProGuard & R8
Guardsquare
Connect with the author
Dexguard
10 min read
| June 10, 2025
Drawbacks of the Google Play Integrity API for Mobile App Attestation
Read More
Android
25 min read
| June 3, 2025
The Evolution of Phishing-Based Malware Attacks on Banking Apps
Read More
Protection
6 min read
| May 27, 2025
Secure Mobile Payments: Protect Wallets and SoftPOS from Cyber Threats
Read More
General Terms | Privacy Policy | Cookie Policy | Security
Tervuursevest 362 bus 1, 3000 Leuven, Belgium |
VAT: BE0550675829 |
© 2016-2025 Guardsquare nv. All rights reserved.
Guardsquare Team - Jun 2024
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:
Then specify this file in your ProGuard configuration using the
-obfuscationdictionary
option.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,
The Guardsquare Team