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

数据解析出错 #255

Open
ChunmingWu opened this issue Jul 24, 2024 · 6 comments
Open

数据解析出错 #255

ChunmingWu opened this issue Jul 24, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@ChunmingWu
Copy link

框架版本【必填】

11.8

问题描述【必填】

升级targetSDKVersion至34(Gradle 8.2.1,JDK 17),打release包进行网络请求时出现数据解析问题。若是 minifyEnabled 为false则无问题。确认已按照框架要求填写混淆规则。我另一个应用的框架版本是12.8,也遇到同样问题。
问题定位到Type类型为class java.lang.Void,所以无论用什么模板解析都失败。
我尝试使用Demo去复现,但因为gradle版本和JDK版本问题,Demo同步失败。

复现步骤【必填】

targetSDKVersion升至34, minifyEnabled 为true,打包运行应用进行网络请求就会出现

是否必现【必填】

项目 targetSdkVersion【必填】

34

出现问题的手机信息【必填】

OPPO CPH1823

出现问题的安卓版本【必填】

Android 10

问题信息的来源渠道【必填】

自己遇到的

是部分机型还是所有机型都会出现【必答】

所有机型

框架最新的版本是否存在这个问题【必答】

框架文档是否提及了该问题【必答】

是否已经查阅框架文档但还未能解决的【必答】

issue 列表中是否有人曾提过类似的问题【必答】

是否已经搜索过了 issue 列表但还未能解决的【必答】

是否可以通过 Demo 来复现该问题【必答】

提供报错堆栈

No response

提供截图或视频

EaSYHttp

提供解决方案

No response

@ChunmingWu ChunmingWu added the bug Something isn't working label Jul 24, 2024
@ChunmingWu
Copy link
Author

我的临时解决方案是不混淆有网络请求的类 -keep class com.xxx.xxx.ui.activity.** { ; }(PS:仅不混淆内部类也可以.$* { *; })。我哥说:看了一下编译后的文件,自动生成了一个内部类文件导致的

@getActivity
Copy link
Owner

image

@ChunmingWu 你确定这个问题文档上面没有写?

@Spikoss
Copy link

Spikoss commented Oct 28, 2024

同步请求的时候的确是有混淆的问题,一样的代码编译运行时没问题,混淆打包后有问题,但是异步混淆打包也没问,同步请求和异步请求的代码如下:同步请求:
` PostRequest postRequest = EasyHttp.post(ApplicationLifecycle.getInstance())
.schedulers(ThreadSchedulers.IO);
try {
HttpData baseBean = postRequest
.api(new UploadImgFileApi()
.setParamsWithFile(stepId, state, "", imgFile))
.execute(new ResponseClass<HttpData >() {
});
LogUtil.i(TAG, "uploadImgSyn--服务器返回结果:" + baseBean, false, true);
if (baseBean != null && baseBean.getStatus() != null
&& baseBean.getStatus().equals("success") && baseBean.getResult() != null) {
return "";
} else {
return "baseBean = null" + baseBean;
}

    } catch (Throwable e) {
        LogUtil.e(TAG, "上传图片失败 Exception:" + e.getMessage(), false, true);
        return "Exception:" + e.getMessage();
    }`

异步请求:
`EasyHttp.post(ApplicationLifecycle.getInstance())
.schedulers(ThreadSchedulers.IO)
.api(new UploadImgFileApi()
.setParamsWithFile(stepId, state, "", imgFile))
.request(new OnHttpListener<HttpData >() {
@OverRide
public void onHttpSuccess(HttpData baseBean) {
LogUtil.i(TAG, "upload--onHttpSuccess:" + baseBean.toString(), false, true);
}

                @Override
                public void onHttpFail(Throwable e) {
                    LogUtil.e(TAG, "upload--onHttpFail:" + e.getMessage(), false, true);
                }

            });`

@Spikoss
Copy link

Spikoss commented Oct 28, 2024

应该是ResponseClass<HttpData>被混淆了,并且即使异步,如果泛型里是List集合,也会被混淆,如:HttpData<List>

@getActivity
Copy link
Owner

image

@getActivity
Copy link
Owner

getActivity commented Oct 29, 2024

同步请求的时候的确是有混淆的问题,一样的代码编译运行时没问题,混淆打包后有问题,但是异步混淆打包也没问,同步请求和异步请求的代码如下:同步请求: ` PostRequest postRequest = EasyHttp.post(ApplicationLifecycle.getInstance()) .schedulers(ThreadSchedulers.IO); try { HttpData baseBean = postRequest .api(new UploadImgFileApi() .setParamsWithFile(stepId, state, "", imgFile)) .execute(new ResponseClass() { }); LogUtil.i(TAG, "uploadImgSyn--服务器返回结果:" + baseBean, false, true); if (baseBean != null && baseBean.getStatus() != null && baseBean.getStatus().equals("success") && baseBean.getResult() != null) { return ""; } else { return "baseBean = null" + baseBean; }

    } catch (Throwable e) {
        LogUtil.e(TAG, "上传图片失败 Exception:" + e.getMessage(), false, true);
        return "Exception:" + e.getMessage();
    }`

异步请求: `EasyHttp.post(ApplicationLifecycle.getInstance()) .schedulers(ThreadSchedulers.IO) .api(new UploadImgFileApi() .setParamsWithFile(stepId, state, "", imgFile)) .request(new OnHttpListener() { @OverRide public void onHttpSuccess(HttpData baseBean) { LogUtil.i(TAG, "upload--onHttpSuccess:" + baseBean.toString(), false, true); }

                @Override
                public void onHttpFail(Throwable e) {
                    LogUtil.e(TAG, "upload--onHttpFail:" + e.getMessage(), false, true);
                }

            });`

@Spikoss 你加上这段混淆规则再试一下:

-keep public class * extends com.hjq.http.model.ResponseClass {
    *;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants