简体   繁体   中英

How to make Android lifecycle aware component get called on using Proguard?

I have a lifecycle aware component that is being called from an Activity. It works fine in debug mode. But when minified (Proguard), the lifecyle component doesn't seem to be called. What is the rule to add to proguard-rules.pro ?

After much hassle, I've gotten the answer. Please check below. Original Tweet

-keep the Lifecycle aware component and also the Lifecycle.Event annotations in your proguard-rules.pro file. Original Tweet

-keep public class android.arch.lifecycle.** {
    public protected *;
}

-keepclassmembers class ** {
    @android.arch.lifecycle.OnLifecycleEvent public *;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM