EzResources
object EzResources
宿主资源替换。hook Resources / TypedArray 的 getter,按「包名 + 类型 + 名称」拦截取值。 直接值不注入 APK;模块资源兼容入口通过 ResourcesLoader 绑定宿主资源池。思路来自 HyperCeiler 的 ResourcesTool。
EzResources.setResReplacement("com.miui.home", "drawable", "ic_launcher", R.drawable.my_icon)
EzResources.setObjectReplacement("com.miui.home", "color", "bg", Color.RED)
EzResources.setDensityReplacement("com.miui.home", "dimen", "bar_height", 8f)Content copied to clipboard
包名传 "*" 表示不限宿主,精确匹配优先。hook 按需装、进程级、带稳定 reloadKey,模块不需要持有或摘除。 替换规则按名字存、取值时才对当前挂着的 apk 解析 id,所以 102 热重载换 apk 不会串资源;loader 由新一代先挂新再摘旧。