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

关于莫名其妙的出现java.lang.RuntimeException:Parcelable encountered IOException writing serializable object (name = com.xinlian.cy.app.updataapp.UpdateAppBean) #120

Open
devzwy opened this issue Jan 28, 2019 · 1 comment

Comments

@devzwy
Copy link

devzwy commented Jan 28, 2019

异常:

java.lang.RuntimeException:Parcelable encountered IOException writing serializable object (name = com.xinlian.cy.app.updataapp.UpdateAppBean)。
看着好像是某个实体没有实现serializable接口导致的,仔细研究了还是无果。
最后在UpdateAppManager类的showDialogFragment()函数中看到作者调用了这个代码。
bundle.putSerializable(INTENT_KEY, mUpdateApp);
在UpdateDialogFragment类中看到了
 fragment.setArguments(bundle);
......如此推测觉得是这里出了问题,我是这么改的。

UpdateAppManager

 /**
     * 跳转到更新页面
     */
    public void showDialogFragment() {

        //校验
        if (verify()) return;

        if (mActivity != null && !mActivity.isFinishing()) {
            Bundle bundle = new Bundle();
            //添加信息,
            fillUpdateAppData();
//            bundle.putSerializable(INTENT_KEY, mUpdateApp);
            if (mThemeColor != 0) {
                bundle.putInt(THEME_KEY, mThemeColor);
            }

            if (mTopPic != 0) {
                bundle.putInt(TOP_IMAGE_KEY, mTopPic);
            }

            UpdateDialogFragment
                    .newInstance(mUpdateApp,bundle)
                    .setUpdateDialogFragmentListener(mUpdateDialogFragmentListener)
                    .show(((FragmentActivity) mActivity).getSupportFragmentManager(), "dialog");

        }

    }

UpdateDialogFragment

 public UpdateDialogFragment(UpdateAppBean mUpdateApp) {
        this.mUpdateApp = mUpdateApp;
    }

 public static UpdateDialogFragment newInstance(UpdateAppBean updateAppBean,Bundle bundle) {
        UpdateDialogFragment fragment =  new UpdateDialogFragment(updateAppBean);
        if (bundle != null) {
            fragment.setArguments(bundle);
        }
        return  fragment;
    } 

 private void initData() {
     //  mUpdateApp = (UpdateAppBean) getArguments().getSerializable(UpdateAppManager.INTENT_KEY);
        //设置主题色
        initTheme();


        if (mUpdateApp != null) {
            //弹出对话框
            final String dialogTitle = mUpdateApp.getUpdateDefDialogTitle();
            final String newVersion = mUpdateApp.getNewVersion();
            final String targetSize = mUpdateApp.getTargetSize();
            final String updateLog = mUpdateApp.getUpdateLog();

            String msg = "";

            if (!TextUtils.isEmpty(targetSize)) {
                msg = "新版本大小:" + targetSize + "\n\n";
            }

            if (!TextUtils.isEmpty(updateLog)) {
                msg += updateLog;
            }

            //更新内容
            mContentTextView.setText(msg);
            //标题
            mTitleTextView.setText(TextUtils.isEmpty(dialogTitle) ? String.format("是否升级到%s版本?", newVersion) : dialogTitle);
            //强制更新
            if (mUpdateApp.isConstraint()) {
                mLlClose.setVisibility(View.GONE);
            } else {
                //不是强制更新时,才生效
                if (mUpdateApp.isShowIgnoreVersion()) {
                    mIgnore.setVisibility(View.VISIBLE);
                }
            }

            initEvents();
        }
    }

我知道这样只能解燃眉之急,最好的解决方案还待作者更新。希望对你们有帮助~ 首页Mac破解版软件,有需要的请拿之~😄

@xuxin3101
Copy link

这个问题我也遇到了,我找到我的原因了,你们也可以看一下,其实这个也算是组件的问题,也不算组件的问题,这种情况一般是当有多个异步调用展示窗口的时候发生冲突会触发这个exception,我的情景是检查更新,并同时有个线程检测是否登录,然后检测到了没有登录跳转了登录界面,然后由于这个activity的资源没有释放,检测到需要更新的时候也会去调用展示升级界面的命令,冲突就在这里了,解决方法其实很简单,找到冲突的地方,释放掉这个activity的资源,如我的情形是startActivity()之后接一句XXXXActivity.this.finsh();这样就ojbk了,而且作者明显不更新了,如果你不想换组件又不想改源码的话就这么改吧 @devzwy

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