Jérôme Gully
07/03/2023, 4:34 PM@Composable
fun TriggeredOnResume(block: () -> Unit) {
// ...
}
Thus, the module is built as an aar artifact, and with obfuscation, but the package containing TriggeredOnResume
is kept with -keep public class com.xx.xx.package.** { *; }.
However, consuming the aar in the app and invoking this Composable function, a NoSuchMethodError
runtime crash happens for TriggeredOnResume
.
I inspected the generated library AAR and discovered that the problematic Compose function was lacking the @Composable
annotation.
To address this, I included a rule to the Proguard file to retain that annotation and now the app no longer crashes.
Is this strictly necessary to add the Proguard rule to avoid the crash? Could I be overlooking something?"
Rule added (doc): -keepattributes RuntimeInvisibleAnnotations
-> Not-working version: public fun TriggeredOnResume(block: () -> kotlin.Unit): kotlin.Unit { /* compiled code */ }
-> Working version (with proguard annotation rules): @androidx.compose.runtime.Composable public fun TriggeredOnResume(block: () -> kotlin.Unit): kotlin.Unit { /* compiled code */ }
is it something known? And is my solution the right one?
Thanks in advance for the reading and the answers 🙂