I have a neat function that does something in appearance:
fun<T : View> Activity.withView(nr : Int, fn : T.()->Unit) { (findViewById(nr) as T?)?.fn() }
Now, when I use this function in my activity:
withView<Spinner>(R.id.spinner_toolbar) { adapter = AdapterIndeksuDlaSpinnera( this@NewMainActivity , PlaylistIndex)
... everything is fine until I use ProGuard. I see that AdapterIndeksuDlaSpinnera gets crippled, as expected, but the application fails when it runs with "Cannot load AdapterIndeksuDlaSpinnera class" (while it must complain about the name of the adapted adapter).
I managed to create a temporary workaround by disabling the manipulation of all adapters that can be used inside my withView
-keep class pl.qus.xenoamp.adapter.** { *; }
but I donβt think this is a good solution (and I donβt know what other classes can fail this way!). So can anyone explain what the problem is, and which ProGuard line should be added to potentially fix similar occurrences of other classes used inside withView ?
source share