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

关于aar包脱糖的问题 #102

Open
SagoLu opened this issue Nov 22, 2023 · 3 comments
Open

关于aar包脱糖的问题 #102

SagoLu opened this issue Nov 22, 2023 · 3 comments

Comments

@SagoLu
Copy link
Contributor

SagoLu commented Nov 22, 2023

在对aar包进行加固时,会先转成dex再处理,但是这一步是经过了D8的脱糖,此时路径下的内部类也会进行加固。但是在打包的时候,是通过处理aar解压出来的classes.jar,这个class的压缩包是没有进行脱糖的,当方法体被移除时,方法体内部的匿名内部类也会被移除,最后打包出来的apk会出现找不到内部类的异常。
目前我的解决办法是使用dex2jar先进行脱糖,在最后打包的时候使用脱糖过后的jar。

@maoabc
Copy link
Owner

maoabc commented Nov 22, 2023

嗯,是有这个问题。加固经过proguard处理后的class文件应该能减少这类问题。r8/d8记得有dex转class功能,不知道有没有脱糖混淆后输出jar功能

@maoabc
Copy link
Owner

maoabc commented Nov 22, 2023

看了一下r8,输入可以是class跟dex,输出默认为dex(如果指定--classfile输出则是class)。aar加固的话可以先使用自己内部混淆规则用r8处理class得到classes.jar(这步包含脱糖),然后aar中的混淆规则变为保留classes.jar中所有类,防止引用后被再度混淆。
做了上面这步再使用aar相关加固应该没什么问题。

@SagoLu
Copy link
Contributor Author

SagoLu commented Nov 27, 2023

看了一下r8,输入可以是class跟dex,输出默认为dex(如果指定--classfile输出则是class)。aar加固的话可以先使用自己内部混淆规则用r8处理class得到classes.jar(这步包含脱糖),然后aar中的混淆规则变为保留classes.jar中所有类,防止引用后被再度混淆。 做了上面这步再使用aar相关加固应该没什么问题。

我之前就尝试过了,用R8的classfile最后只会生成一个空的jar包

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

No branches or pull requests

2 participants