Skip to content

Commit 04509d3

Browse files
committed
release: keep all classes under module package to fix ARouter Class.forName failing under R8 minify
1 parent f84839b commit 04509d3

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

app/proguard-rules.pro

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,14 @@
448448

449449
# ============ Keep all Activities and Fragments ============
450450

451-
-keep class com.shuyu.github.kotlin.module.** extends android.app.Activity { *; }
452-
-keep class com.shuyu.github.kotlin.module.** extends androidx.fragment.app.Fragment { *; }
451+
# ARouter 通过路由表里的全限定类名字符串反射加载 Activity / Fragment,
452+
# 必须保留 module 包下所有类的「类名」(成员仍允许混淆/优化),否则启动时
453+
# Postcard.navigation 会因 Class.forName 失败抛 "Init provider failed"。
454+
-keep class com.shuyu.github.kotlin.module.** { *; }
455+
-keepnames class com.shuyu.github.kotlin.module.**
456+
457+
# 所有 ARouter 注解的目标类(额外保险,保证 @Route 标注的 class 不被裁剪)
458+
-keep @com.alibaba.android.arouter.facade.annotation.Route class * { *; }
453459

454460
# ============ Kotlin Serialization (if used) ============
455461

0 commit comments

Comments
 (0)