liujingxing / rxhttp

🔥🔥🔥 Based on OkHttp encapsulation, support Kotlin Coroutines、RxJava2、RxJava3; 30s to get started.
https://juejin.im/post/5ded221a518825125d14a1d4
Apache License 2.0
3.74k stars 457 forks source link

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

Closed bravetou closed 10 months ago

bravetou commented 10 months ago
    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 commented 10 months ago

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

bravetou commented 10 months ago
# 保持实体类不被混淆
-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 commented 10 months ago

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

liujingxing commented 10 months ago

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

bravetou commented 10 months ago
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 commented 10 months ago

已增加Gson混淆,谢谢

liujingxing commented 10 months ago

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