Is this actually a thing?
# android
l
Is this actually a thing?
đźš« 2
g
The OP had a specific requirement to not obfuscate data classes at all. To whitelist them in one batch, like
data class
is a type or something. Do you have similar restrictions?
l
I don't have any restriction. My app is just crashing when trying to cast a Data Class to itself. Randomly crashes
d
I think theres an alternative to proguard that works better
Dont quote me on that though
With kotlin*
k
what does “randomly crashes” mean? is it a new exception each time? is it in a new line of the code each time? you should make a Stack Overflow post I think also, the alternative to Proguard from Google that perhaps Dico was referring to is called R8 (but I don’t have any info to know that its better for Kotlin or not)
j
I’m new to Android but I’ve used ProGuard before back in the J2ME days circa 2003. It’s a mature well tested project, and as far as I know it operates directly on bytecode. I’d be surprised if it contains fundamental bugs of this sort. However, I don’t know how Kotlin maps things like data classes into Java bytecode so I’m not saying it’s definitely not an issue. I’d write a minimal example to see if it’s reproducible. Doing this might help you realise an issue on your side (or prove that it’s a bug).
l
The random crashes is that the same line of code (a cast of a Sealed class to a Data Class that inherits it) works, unless it's an OnRestoreInstance, in which Proguard screws up and I get a class cast exception (something like
a.b.c$a
cannot be cast to
a.b.c$b
. If I add
@Keep
to the data class, it works
IDK if this is a bug in pro guard or if I'm doing something wrong
k
maybe check the proguard mapping file to see what the classes are you can also decompile to see the code where it happens
z
I'm using `data class`es with Proguard and don't see any problems in production.