u

    ursus

    1 year ago
    Hi, I have code like this
    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

    1 year ago
    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

    1 year ago
    hm but then I need to map strings to classes right?
    t

    Tom Hermann

    1 year ago
    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.