[英]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. 它在
debug
模式下工作正常。 But when minified (Proguard), the lifecyle component doesn't seem to be called. 但是,当最小化(Proguard)时,似乎不会调用lifecyle组件。 What is the rule to add to
proguard-rules.pro
? 添加到
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. -keep
在proguard-rules.pro
文件中-keep
了解生命周期的组件以及Lifecycle.Event
批注。 Original Tweet 原始推文
-keep public class android.arch.lifecycle.** {
public protected *;
}
-keepclassmembers class ** {
@android.arch.lifecycle.OnLifecycleEvent public *;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.