Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复第三方库混淆出r文件与R文件冲突导致报错问题。eg:Caused by: java.lang.RuntimeException: ca… #465

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

smuwjs
Copy link

@smuwjs smuwjs commented Sep 13, 2021

背景:
项目打包时遇到很多第三方库混淆时会出现第三方库包名+r文件与项目生成的第三方库包名+R文件冲突导致报错问题,使用Robust才会报错,不使用是正常的。有的第三方库无法联系到开发者,如果能在Robust层面上解决,会是一种比较好的方式。

有问题的第三方库:
华为推送:maven { url 'http://developer.huawei.com/repo/' } com.huawei.hms:push:5.0.3.301

报错:
Caused by: java.lang.RuntimeException: cannot find com.huawei.hms.hatool.r: com.huawei.hms.hatool.R found in com/huawei/hms/hatool/r.class
at javassist.CtClassType.getClassFile2(CtClassType.java:202)
at javassist.CtClassType.getModifiers(CtClassType.java:407)
at robust.gradle.plugin.asm.AsmInsertImpl.insertCode(AsmInsertImpl.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

功能说明:
尝试directoryInputs和jarInputs分别用独立的ClassPool可以修复,目前未发现更好的办法。

备注:
测试暂未发现BUG,准备上到线上环境,可以看看是否有问题。

…nnot find com.huawei.hms.hatool.r: com.huawei.hms.hatool.R found in com/huawei/hms/hatool/r.class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant