AndResGuard
AndResGuard copied to clipboard
开启混淆后,fontFamily失效
项目里面使用support包全局替换了字体,如果使用resguard打包,替换的字体无效。 theme是这样设置的:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="fontFamily">@font/my_font</item>
<item name="android:fontFamily" tools:targetApi="jelly_bean">@font/my_font</item>
<item name="android:textViewStyle">@style/myTextViewStyle</item>
<item name="android:buttonStyle">@style/myButtonStyle</item>
<item name="android:editTextStyle">@style/myEditTextStyle</item>
</style>
<style name="myTextViewStyleBold" parent="@android:style/Widget.TextView">
<item name="android:fontFamily" tools:targetApi="jelly_bean">@font/bold</item>
<item name="fontFamily">@font/bold</item>
</style>
<style name="myTextViewStyle" parent="@android:style/Widget.TextView">
<item name="android:fontFamily" tools:targetApi="jelly_bean">@font/normal</item>
<item name="fontFamily">@font/normal</item>
</style>
<style name="myButtonStyle" parent="Widget.AppCompat.Button">
<item name="android:fontFamily" tools:targetApi="jelly_bean">@font/bold</item>
<item name="fontFamily">@font/bold</item>
</style>
<style name="myEditTextStyle" parent="Widget.AppCompat.EditText">
<item name="android:fontFamily" tools:targetApi="jelly_bean">@font/normal</item>
<item name="fontFamily">@font/normal</item>
</style>
问题解决了,添加了res pathh mapping
res path mapping:
res/font -> res/font
res/font-v22 -> res/font-v22
但是还是希望各位大神能再以后的版本里面优化一下,不用添加白名单
这个是加在哪个文件里
@Reginer 参考一下这个~
https://github.com/shwenzhang/AndResGuard/blob/master/README.zh-cn.md#白名单
https://github.com/shwenzhang/AndResGuard/blob/1caaa5c12608fcb213e1064eb5b4f94f588f253f/AndResGuard-example/app/resource_mapping.txt#L1-L6
之前没仔细看,原来还有个resource_mapping.txt文件
@imknown emm,之前还没注意有这东西
我在 res path mapping:
里面加了 res/font -> res/font
和 res/font-v22 -> res/font-v22
后报错,错误是 ... is not equal, there must be some problem
这个异常是ResourceApkBuilder#generalUnsignApk()里面抛出来的,我看了 https://github.com/shwenzhang/AndResGuard/issues/302 单 res 文件夹路径 keep 这个issue也是这个异常
AndResGuard-cli-1.2.15.jar 和 AndResGuard-cli-1.1.16.jar 测试过都是这样子
@lecymeng 可否提供下APK,我本地调试下
@lecymeng 可否提供下APK,我本地调试下
APK链接: https://c-t.work/s/61c5d0a3fb7e42
TextView字体设置是 app:fontFamily="@font/din_bold"
混淆后 不会crash,但是没有效果
在Java/Kotlin里面设置字体,例如 textPaint.typeface = ResourcesCompat.getFont(context, R.font.din_bold)
会Crash,异常是Resource Not Found Exception
目前只能暂时把字体改到assets目录下 来设置字体
Any update about this issue? I am facing the same problem, maybe AndResGuard can be support font resources automatically thx