https://kotlinlang.org logo
u

ursus

11/22/2020, 2:22 AM
Hi, I have code like this
Copy code
fun <T> get(klass: Class<T>): T = store.getOrNull(klass) ?: error("No such component '$klass' found")
issue is my release builds are obviously proguarded, so the exception logs obviously read "No such component 'ndsjadnjka.dqw.DWQ' found" Is there a sane way around it other than whitelisting component classes to not have them renamed (which might or not be a security issue)? Maybe somehow leverage firebase crashlytics already knowing the proguard mappings?
t

Tom Hermann

11/23/2020, 5:58 PM
You could use Proguard’s
keepnames
if it is important that value be human readable. You could switch your store to work in terms of strings, and just pass the literal name of the store you want access to. e.g.
store.get("users")
You may be able to deobfuscate using the mapping file, see: https://www.guardsquare.com/en/products/proguard/manual/retrace I would opt for passing a literal string if you don’t want to fight classname obfuscation. I generally avoid using classnames for tags, logging, caching, etc unless I’m only doing it transiently within the scope of my process.
u

ursus

11/25/2020, 8:05 PM
hm but then I need to map strings to classes right?
t

Tom Hermann

11/30/2020, 3:48 PM
Back in the day I would just have a public static final string in classes called TAG or something like that, so UserInputFragment.TAG would be the string “userInputFragment”. It’s not elegant, but you are in control of it.
5 Views