PenguinDan
PenguinDan

Reputation: 934

Android class canonical name uniqueness after Obfuscation

Are class canonical names unique within a package after obfuscation?

I currently use Koin Dependency Injection and create scopes based off of the Activity's and Fragment's canonical names automatically for some shared DI logic. Previously, I was using their simpleName which, of course, are not unique after obfuscation.

Upvotes: 1

Views: 569

Answers (1)

Ryan M
Ryan M

Reputation: 20147

Yes, class names within a package (that is, the fully qualified class name) must be unique.

This rule applies at the virtual machine level: if two classes have the same fully qualified name, only one of them will actually be loaded, and it's somewhat arbitrary which one gets loaded. This can lead to fairly strange bugs if this rule isn't followed.

Thus, any properly functioning obfuscator must follow this rule. If it does not, that would be a bug in the obfuscator.

Upvotes: 1

Related Questions