shwenzhang / AndResGuard

proguard resource for Android by wechat team
Apache License 2.0
8.54k stars 1.54k forks source link

不同分辨率的string.xml,资源混淆压缩后会出现ResourceNotFound的异常 #100

Closed changety closed 7 years ago

changety commented 8 years ago

比如: popo_2016-10-08 11-09-02 下面的同名字符串,在运行时会报错

simpleton commented 8 years ago

收到,我晚些时候确认一下。

simpleton commented 8 years ago

我尝试在example复现,并没有出现问题。你可以看下AndResGuard-example的情况是否和你描述的相符。

changety commented 8 years ago

这个问题可能并不一定能复现,我自己测试也没有复现,但确实收集到过这个异常

simpleton commented 8 years ago

可否把异常的callstack以及机型,sdk版本发出来呢?

changety commented 8 years ago

android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f080016 at android.content.res.Resources.getResourcePackageName(Resources.java:1868) at android.content.res.Resources.getYLThemeString(Resources.java:2891) at android.content.res.Resources.getText(Resources.java:253) at android.content.res.Resources.getString(Resources.java:349) at android.content.Context.getString(Context.java:337)

changety commented 8 years ago

popo_2016-10-10 14-50-15

simpleton commented 8 years ago

多谢反馈,我再排查一下问题。

thearyong commented 8 years ago

我也遇到同样的问题,在app 运行umeng分享的时候 crash. 1.异常信息:

android.content.res.Resources$NotFoundException: File res/mipmap-xxxhdpi-v4/ic_launcher.png from drawable resource ID #0x7f030000
                                                                       at android.content.res.Resources.openRawResourceFd(Resources.java:1315)
                                                                       at com.umeng.socialize.media.g$g.a(SourceFile:546)
                                                                       at com.umeng.socialize.media.g.i(SourceFile:219)
                                                                       at com.umeng.socialize.media.c.b(SourceFile:120)
                                                                       at com.umeng.socialize.media.c.a(SourceFile:61)
                                                                       at com.umeng.socialize.handler.UMQQSsoHandler.a(SourceFile:327)
                                                                       at com.umeng.socialize.handler.UMQQSsoHandler.g(SourceFile:304)
                                                                       at com.umeng.socialize.handler.UMQQSsoHandler.a(SourceFile:99)
                                                                       at com.umeng.socialize.c.a.a(SourceFile:404)
                                                                       at com.umeng.socialize.h.a(SourceFile:208)
                                                                       at com.umeng.socialize.h.b(SourceFile:198)
                                                                       at com.umeng.socialize.common.d.run(SourceFile:134)
                                                                       at android.os.Handler.handleCallback(Handler.java:739)
                                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                       at android.os.Looper.loop(Looper.java:148)
                                                                       at android.os.HandlerThread.run(HandlerThread.java:61)
                                                                    Caused by: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
                                                                       at android.content.res.AssetManager.openNonAssetFdNative(Native Method)
                                                                       at android.content.res.AssetManager.openNonAssetFd(AssetManager.java:426)

2.引用代码:

.withMedia(new UMImage(activity, R.mipmap.ic_launcher))

3.白名单:

andResGuard {
    mappingFile = file("./resource_mapping.txt")
    use7zip = true
    useSign = true
    keepRoot = false
    whiteList = [
            // your icon
//            "R.drawable.icon",
            "R.mipmap.*",
            // for fabric
            "R.string.com.crashlytics.*",

4.机型:Nexus 6 - 6.0系统

每次都必现,添加白名单了,后面还是提示可能被压缩,我不知是不是白名单规则填写有误?

simpleton commented 8 years ago

@thearyong 多谢反馈,ref #92

thearyong commented 8 years ago

@simpleton 感谢,找到原因了,是我之前把ic_launcher.png经过https://tinypng.com 处理过一次,并不是AndResGuard白名单问题。 解决方法:替换原来的ic_launcher.png,正常运行

OsBelief commented 8 years ago

@thearyong ,请问这个报错和 https://tinypng.com 处理过有什么关系啊