docs: update r8-proguard

This commit is contained in:
2025-12-14 21:19:25 +08:00
parent 4676d980e0
commit da5ce011f3
2 changed files with 14 additions and 10 deletions

View File

@@ -3,16 +3,18 @@
> In most scenarios, app packages can be compressed through obfuscation. > In most scenarios, app packages can be compressed through obfuscation.
> Here is an introduction to how to configure obfuscation rules. > Here is an introduction to how to configure obfuscation rules.
`Hikage` does not require additional configuration of obfuscation rules, since `View` objects loaded by Hikage do not need to be defined in XML, they can be equally obfuscated. `Hikage` itself does not require additional configuration of obfuscation rules, since `View` objects created by Hikage do not need to be defined in XML, they can be equally obfuscated.
You can force them to be obfuscated with your custom `View`, such as `com.yourpackage.YourView`, using the following rules. However, please note that if a custom `View` is not defined in XML, the latest R8 rules will choose to obfuscate it. To prevent the constructor from being lost, you still need to add the following rules to avoid problems.
``` ```
-allowobfuscation class com.yourpackage.YourView -keep,allowobfuscation class * extends android.view.View {
<init>(...);
}
``` ```
If you must prevent `Hikage` from being obfuscated or if something occurs after being obfuscated, you can use the following rules to prevent `Hikage` from being obfuscated. If `Hikage` itself encounters problems after being obfuscated, you can use the following more aggressive rules to prevent `Hikage` from being obfuscated.
``` ```
-keep class com.highcapable.hikage** -keep class com.highcapable.hikage.**
``` ```

View File

@@ -2,16 +2,18 @@
> 大部分场景下应用程序安装包可通过混淆压缩体积,这里介绍了混淆规则的配置方法。 > 大部分场景下应用程序安装包可通过混淆压缩体积,这里介绍了混淆规则的配置方法。
`Hikage` 不需要额外配置混淆规则,由于 Hikage 装载的 `View` 不需要在 XML 中被定义,它们也可以同样被混淆。 `Hikage` 自身不需要额外配置混淆规则,由于 Hikage 装载的 `View` 不需要在 XML 中被定义,它们也可以同样被混淆。
你可以将你的自定义 `View`,例如 `com.yourpackage.YourView` 使用以下规则强制让它们被混淆 但是请注意,如果自定义 `View` 没在 XML 中被定义,最新的 R8 规则将选择对其进行混淆,为了防止构造方法丢失,你依然需要添加以下规则以避免出现问题
``` ```
-allowobfuscation class com.yourpackage.YourView -keep,allowobfuscation class * extends android.view.View {
<init>(...);
}
``` ```
如果你一定要防止 `Hikage` 被混淆或者混淆后发生了问题,那么你可以使用以下规则来防止 `Hikage` 被混淆。 如果 `Hikage` 自身被混淆后发生了问题,那么你可以使用以下比较强硬的规则来防止 `Hikage` 被混淆。
``` ```
-keep class com.highcapable.hikage** -keep class com.highcapable.hikage.**
``` ```