Skip to content

Commit 4b0ac56

Browse files
committed
fix: keep ComponentCallbacks2 implementations from R8 devirtualization
R8 aggressively optimized ComponentAppearanceCallback's empty onTrimMemory/ onLowMemory bodies, causing the Class object itself to be registered as a ComponentCallbacks2 instead of the instance. When Android dispatched onTrimMemory on backgrounding, this threw AbstractMethodError on java.lang.Class<cm> and crashed the release build. Add a ProGuard keep rule to preserve all ComponentCallbacks2 implementations' interface methods intact.
1 parent 7d0147b commit 4b0ac56

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

app/proguard-rules.pro

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
-keep public class io.github.muntashirakon.AppManager.servermanager.** { *; }
3939
-keep public class io.github.muntashirakon.AppManager.server.** { *; }
4040
-keep public class io.github.muntashirakon.AppManager.ipc.** { *; }
41+
# Keep ComponentCallbacks2 implementations intact — R8 can devirtualize empty
42+
# onTrimMemory/onLowMemory bodies and merge the class, causing
43+
# AbstractMethodError when Android dispatches onTrimMemory to the callback list.
44+
-keep class * implements android.content.ComponentCallbacks2 {
45+
void onTrimMemory(int);
46+
void onLowMemory();
47+
void onConfigurationChanged(android.content.res.Configuration);
48+
}
4149
# Don't minify debug-sepcific resource file
4250
-keep public class io.github.muntashirakon.AppManager.debug.R$raw {*;}
4351
# Don't minify OpenPGP API

0 commit comments

Comments
 (0)