简体   繁体   English

如何使用Proguard调用可识别Android生命周期的组件?

[英]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. -keepproguard-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.

相关问题 我们可以将 android.app.Service 作为生命周期感知组件吗 - Can we make android.app.Service as lifecycle aware component 如何使用Android Studio使Proguard混淆 - How to make Proguard obfuscate using Android Studio 需要权限的生命周期感知组件 - Lifecycle Aware Component that needs Permission Android - Jetpack - 让懒惰地创建 class 生命周期感知 - Android - Jetpack - Make lazily created class lifecycle aware 使用 LifecycleObserver 的生命周期感知组件如何感知屏幕方向变化 - How can lifecycle aware components using LifecycleObserver be aware of screen orientation changes 使用Proguard时如何在Android Monitor中获取真实的类名 - How to get real class names in Android Monitor when using Proguard 如何安全地(生命周期感知).collectAsState() 一个 StateFlow? - How to safely (lifecycle aware) .collectAsState() a StateFlow? Android EventBus和组件生命周期 - Android EventBus and Component LifeCycle 如何使用 Hilt 创建生命周期感知组件? - How to create lifecycle aware components with Hilt? 如何在 Android 的生命周期感知协程范围内返回函数值? - How do I return function value in lifecycle-aware coroutine scope in Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM