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

未使用混淆之前可以正常网络请求,使用混淆之后无法正常网络请求 #472

Closed
bravetou opened this issue Nov 1, 2023 · 7 comments

Comments

@bravetou
Copy link

bravetou commented Nov 1, 2023

    def rxhttp_version = '3.0.6'
    implementation 'com.squareup.okhttp3:okhttp:4.10.0'
    implementation "com.github.liujingxing.rxhttp:rxhttp:$rxhttp_version"`
@Param(methodName = "postEncryptForm")
class PostEncryptFormParam(url: String?) : FormParam(url, Method.POST) {
    override fun getRequestBody(): RequestBody? {
        val allParam = mutableMapOf<String, Any>()
        // 获取到所有通过add系列方法添加的参数
        bodyParam.forEach {
            allParam[it.key] = it.value
        }
        // 获取到所有通过addQuery系列方法添加的参数
        queryParam?.forEach {
            allParam[it.key] = it.value
        }
        LogUtils.json("RxHttp", allParam)
        val signs = allParam.encryptParamAES(false)
        // 重新组装请求体
        bodyParam.clear()
        queryParam?.clear()
        bodyParam.add(KeyValuePair("signs", signs))
        return super.getRequestBody()
    }
}
@liujingxing
Copy link
Owner

具体什么问题?另外,你自己的实体类记得keep

@bravetou
Copy link
Author

bravetou commented Nov 1, 2023

# 保持实体类不被混淆
-keep class org.jutuina.com.tuinapro.bean.**{*;}
-keep class org.jutuina.com.tuinapro.core.net.Response{*;}
# -keep class org.jutuina.com.tuinapro.core.net.GetEncryptParam {*;}
# -keep class org.jutuina.com.tuinapro.core.net.PostEncryptFormParam {*;}
# -keep class org.jutuina.com.tuinapro.core.net.PostEncryptJsonParam {*;}

混淆了的,具体就是项目中使用了AES(allParam.encryptParamAES(false))加密所有参数,生成一个新的signs参数,未混淆时一切正常,混淆之后就直接报网络请求失败

@liujingxing
Copy link
Owner

liujingxing commented Nov 1, 2023

错误日志你要发出来,不用多想,肯定是混淆的问题

@liujingxing
Copy link
Owner

我需要错误日志,请求失败具体什么表现,比如,请求发出来没,请求回来了没?RxHttp初始化的的时候通过setDebug(true),随后就会有详细的请求日志

@bravetou
Copy link
Author

bravetou commented Nov 1, 2023

21:10:36.269  E  Request end Log printing failed
21:10:36.269  E  java.lang.IllegalStateException: TypeToken must be created with a type argument: new TypeToken<...>() {}; When using code shrinkers (ProGuard, R8, ...) make sure that generic signatures are preserved.

@bravetou
Copy link
Author

bravetou commented Nov 1, 2023

已增加Gson混淆,谢谢

@liujingxing
Copy link
Owner

liujingxing commented Nov 1, 2023

晓得了,你应该升级了AGP 8.0,默认开启了R8 full mode,该模式下,混淆时会将泛型擦除,RxHttp v3.2.1也对该模式进行了兼容 #471

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